Hey guys,
I have a big problem and I hope that you can help me I want to print all of the filter fields (all of the offers) in a pivot table, and print the tables one below another to the same page. Iīm trying with the following code:
Dim PvtTbl1 As PivotTable
Dim pvtFld1 As PivotField
Dim pi1 As PivotItem
Dim wsData1 As Worksheet
Dim rngData1 As Range
Dim PvtTblCache1 As PivotCache
Dim wsPvtTbl1 As Worksheet
Set wsData1 = Worksheets("Uber")
Set wsPvtTbl1 = Worksheets("Uber_opt")
Set rngData1 = wsData1.Range("A1").CurrentRegion
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=rngData1, Version:=xlPivotTableVersion12).CreatePivotTable TableDestination:=wsPvtTbl1.Range("A1"), TableName:="Uber_pivot"
Set PvtTbl1 = wsPvtTbl1.PivotTables("Uber_pivot")
Set pvtFld1 = PvtTbl1.PivotFields("offer")
pvtFld1.Orientation = xlPageField
Set pvtFld1 = PvtTbl1.PivotFields("publisher")
pvtFld1.Orientation = xlRowField
Set pvtFld1 = PvtTbl1.PivotFields("conversions")
pvtFld1.Orientation = xlDataField
Set pvtFld1 = PvtTbl1.PivotFields("revenue")
pvtFld1.Orientation = xlDataField
With PvtTbl1.PivotFields("First Ride")
.Orientation = xlDataField
.Function = xlSum
.NumberFormat = "#,##0"
.Position = 1
End With
For Each pi1 In PvtTbl1.PageFields("offer").PivotItems
PvtTbl1.PageFields("offer").CurrentPage = pi1.Name
PvtTbl1.ManualUpdate = True
Range("A3").End(xlDown).Offset(3, 0).Select
Next pi1
The code rolls down to the last item in the Filter field and prints only that table instead of all of them. Can you help me, please?
Thank you,
Best,
Dani
Bookmarks