Hi, I am trying to create a pivot table using the macro recorder, but it seems that when my range increases the extra rows in my pivot table are not included.
Any ideas how i can solve this?
Many thanks,
Sam
Here is my code
Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Part 5 Pivot Source!R1C1:R3868C34", Version:=xlPivotTableVersion12). _
CreatePivotTable TableDestination:="Sheet8!R3C1", TableName:="PivotTable3" _
, DefaultVersion:=xlPivotTableVersion12
Sheets("Sheet8").Select
Cells(3, 1).Select
ActiveWorkbook.ShowPivotTableFieldList = True
With ActiveSheet.pIVOTtABLES("PivotTable3").PivotFields("Customer_id")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.pIVOTtABLES("PivotTable3").AddDataField ActiveSheet.pIVOTtABLES( _
"PivotTable3").PivotFields("Total Passengers"), "Sum of Total Passengers", _
xlSum
With ActiveSheet.pIVOTtABLES("PivotTable3").PivotFields("Country")
.Orientation = xlRowField
.Position = 2
End With
Range("D3").Select
End Sub
Any ideas how i can solve this?
Many thanks,
Sam
Here is my code
Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Part 5 Pivot Source!R1C1:R3868C34", Version:=xlPivotTableVersion12). _
CreatePivotTable TableDestination:="Sheet8!R3C1", TableName:="PivotTable3" _
, DefaultVersion:=xlPivotTableVersion12
Sheets("Sheet8").Select
Cells(3, 1).Select
ActiveWorkbook.ShowPivotTableFieldList = True
With ActiveSheet.pIVOTtABLES("PivotTable3").PivotFields("Customer_id")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.pIVOTtABLES("PivotTable3").AddDataField ActiveSheet.pIVOTtABLES( _
"PivotTable3").PivotFields("Total Passengers"), "Sum of Total Passengers", _
xlSum
With ActiveSheet.pIVOTtABLES("PivotTable3").PivotFields("Country")
.Orientation = xlRowField
.Position = 2
End With
Range("D3").Select
End Sub