1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| Sub Pivottest()
Dim PTCache As PivotCache
Dim PT As PivotTable
Application.ScreenUpdating = False
Workbooks.Open Filename:=Sheets("Folders").Range("C20").Value
Sheets("Data Base (Client OR Sale").Select
Set PTCache = ActiveWorkbook.PivotCaches.Create( _
SourceType:=xlDatabase, _
SourceData:=Range("A1").CurrentRegion)
Worksheets.Add
Set PT = ActiveSheet.PivotTables.Add( _
PivotCache:=PTCache, _
TableDestination:=Range("A3"))
With PT
.PivotFields("Client category (Sector and Team)").Orientation = xlPageField
.PivotFields("Revenue ").Orientation = xlPageField
.PivotFields("Name").Orientation = xlRowField
.PivotFields("Full Name").Orientation = xlRowField
.PivotFields("SUM").Orientation = xlDataField
.PivotFields("SUM-1").Orientation = xlDataField
.PivotFields("FY-1").Orientation = xlDataField
.PivotFields("Revenue").ClearAllFilters
.PivotFields("Revenue").CurrentPage = "Vente"
'no field captions
.DisplayFieldCaptions = False
End With
ActiveWorkbook.Save
ActiveWindow.Close
End sub |
Partager