1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Sub Creation_TCD_Achats()
Dim num_ligne As Integer
ActiveWorkbook.Sheets("Importation Achats").Select
ActiveSheet.Cells(1, 1).Select
Selection.End(xlDown).Select
num_ligne = ActiveCell.Rows.Row
Set donnees = Range(ActiveSheet.Cells(1, 1), ActiveSheet.Cells(num_ligne, 10))
ActiveWorkbook.Sheets("Base Achats").Select
Cells.Clear
Set pc1 = ActiveWorkbook.PivotCaches.Add(xlDatabase, "'" & donnees.Parent.Name & "'!" & donnees.Address(ReferenceStyle:=xlR1C1))
Set pt1 = pc1.CreatePivotTable(TableDestination:=Worksheets("Base Achats").Cells(3, 1), TableName:="Tableau1", DefaultVersion:=xlPivotTableVersion10)
With ActiveSheet.PivotTables("Tableau1").PivotFields("Article Ref")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("Tableau1").PivotFields("Poids total").Function = xlSum
End Sub |