ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pivot Table via Macro (https://www.excelbanter.com/excel-programming/401742-pivot-table-via-macro.html)

Roger Converse[_2_]

Pivot Table via Macro
 
Hello,

I am trying to record a macro that will create a pivot table based on a
spreadsheet.

I am receiving error Num: 1004

Unable to get the PivotField property of the PivotTable Class.

The code that recorded is below. I am much more familiar with coding in
Access, so don't even know where to start here.

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"tempPO_ExpSumm!C1:C4").CreatePivotTable TableDestination:="",
TableName:= _
"PivotTable4", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable4").PivotFields ("Expeditor")
.Orientation = xlColumnField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable4").PivotFields ("LS_Date")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable4").PivotFields ("PO_Type")
.Orientation = xlRowField
.Position = 2
End With
ActiveSheet.PivotTables("PivotTable4").AddDataFiel d
ActiveSheet.PivotTables( _
"PivotTable4").PivotFields("PO_Count"), "Count of PO_Count", xlCount

Thank you,
Roger



All times are GMT +1. The time now is 12:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com