I have data that is copied to a sheet called "Overaged Inventory") using a macro which copied the data perfectly
once I copied would like a macro set up to create a pivot table in cell M1 onwards
However when running the code, I get invalid procedure or call and rghe code below is highlighted
]code] ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Overaged Inventory!R1C1:R1048576C10", Version:=6).CreatePivotTable _
TableDestination:="Overaged Inventory!R1C13", TableName:="PivotTable4", _
DefaultVersion:=6 [/code]
see full code
it would be appreciated if someone could kindly assist me
once I copied would like a macro set up to create a pivot table in cell M1 onwards
However when running the code, I get invalid procedure or call and rghe code below is highlighted
]code] ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Overaged Inventory!R1C1:R1048576C10", Version:=6).CreatePivotTable _
TableDestination:="Overaged Inventory!R1C13", TableName:="PivotTable4", _
DefaultVersion:=6 [/code]
see full code
Code:
Sub Create_Pivot()
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Demo Overaged Stock!R1C1:R1048576C10", Version:=6).CreatePivotTable _
TableDestination:="Overaged inventory!R1C13", TableName:="PivotTable8", _
DefaultVersion:=6
Sheets("Overaged Inventory").Select
Cells(1, 13).Select
ActiveWorkbook.ShowPivotTableFieldList = True
With ActiveSheet.PivotTables("PivotTable8").PivotFields("Division")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable8").AddDataField ActiveSheet.PivotTables( _
"PivotTable8").PivotFields("Value"), "No. of items", _
xlCount
ActiveSheet.PivotTables("PivotTable8").AddDataField ActiveSheet.PivotTables( _
"PivotTable8").PivotFields("Stand In Value"), "Count of Stand In Value2", _
xlCount
With ActiveSheet.PivotTables("PivotTable8").PivotFields( _
"Count of Stand In Value")
.Caption = "Sum Value"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable8").PivotFields("Division")
.PivotItems("(blank)").Visible = False
End With
Range("M1").Select
ActiveWorkbook.ShowPivotTableFieldList = False
ActiveSheet.PivotTables("PivotTable8").CompactLayoutRowHeader = "Branch"
Range("N1").Select
ActiveSheet.PivotTables("PivotTable8").DataPivotField.PivotItems( _
"Sum Value").Caption = "Value "
Range("O1").Select
ActiveSheet.PivotTables("PivotTable8").PivotFields("Count Value2"). _
Caption = "No. of Units "
Range("N2:O15").Select
Selection.NumberFormat = "#,##0.00"
Range("O5").Select
End Sub
it would be appreciated if someone could kindly assist me