View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Roger Converse[_2_] Roger Converse[_2_] is offline
external usenet poster
 
Posts: 45
Default 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