Sub TCD_TEST_V2()
On Error Resume Next
derl = Range("A2").End(xlDown).Row
Range("A1:T" & derl).Select
ActiveWorkbook.Names.Add Name:="ForTCD", RefersToR1C1:=Selection()
ActiveWorkbook.Names("ForTCD").Delete
ActiveWorkbook.Names.Add Name:="ForTCD", RefersToR1C1:=Selection()
Dim Plg As Range, Nom_TCD
Nom_TCD = InputBox("Nom du TCD?", "TCD", "TCD_N" & Second(Time))
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"ForTCD").CreatePivotTable TableDestination:="", TableName:= _
CStr(Nom_TCD), DefaultVersion:=xlPivotTableVersion10
With ActiveSheet
.PivotTableWizard TableDestination:=.Cells(1, 1)
With .PivotTables(CStr(Nom_TCD))
With .PivotFields("Division")
.Orientation = xlRowField
.Position = 1
End With
With .PivotFields("Article")
.Orientation = xlDataField
.Position = 1
End With
With .PivotFields("Mag.")
.Orientation = xlRowField
.Position = 2
End With
End With
End With
End Sub