Sub impor()
Dim i, j As Variant
Application.ScreenUpdating = False
i = Sheets("TCD").[B2]
'Supression de l'ancien tableau
Sheets(i).Activate
j = [B13]
Application.Goto Reference:="TableauED"
ActiveSheet().ListObjects("TableauED").Unlist
Range("D17", Range("C18").End(xlToRight).End(xlDown)).Select
Selection.ClearContents
Range("A1").Select
Sheets("TCD").Select
Range("D2").Select
' mise à jour des calculs TCD
Sheets("TCD").Activate
Calculate
' copie le tableau
Range("A6", Range("C7").End(xlToRight).End(xlDown)).Select
Selection.Copy Destination:=Sheets(i).Range("D17")
' Convertie les données copiées en tableau
Sheets(i).Select
Range("B18", Range("C18").End(xlToRight).End(xlDown)).Select
Sheets(i).ListObjects.Add(xlSrcRange, Range("$B$18", Range("C18").End(xlToRight).End(xlDown)), , xlYes).Name = "TableauED"
Range("TableauED[[#All],[RangR]]").Select
Calculate
Range("B18").Select
'Trie du tableau
ActiveWorkbook.Worksheets(i).ListObjects("TableauED").Sort.SortFields _
.Clear
ActiveWorkbook.Worksheets(i).ListObjects("TableauED").Sort.SortFields _
.Add Key:=Range("TableauED[[#All],[RangR]]"), SortOn:=xlSortOnValues, Order _
:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets(i).ListObjects("TableauED").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Application.ScreenUpdating = True
End Sub