idlewyld89
New Member
- Joined
- Jun 10, 2018
- Messages
- 23
Alright so I've written 90% of my program by hand, and I figured one part that would be ideal to simply record once all the manual sorting is out of the way would be the Pivot Table formatting. For some reason, I get the following error from the below code:
Runtime Error 5: Invalid Procedure Call or Argument
I use the automated method of adding a pivot table (Insert > Pivot Table) and assumed that would be the least likely to cause problems as Excel is already doing most of the work itself...
The error occurs on the 2nd line.
Runtime Error 5: Invalid Procedure Call or Argument
I use the automated method of adding a pivot table (Insert > Pivot Table) and assumed that would be the least likely to cause problems as Excel is already doing most of the work itself...
The error occurs on the 2nd line.
Code:
Sub RegReport()
Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"REGTable", Version:=6).CreatePivotTable TableDestination:="Sheet32!R3C1", _
TableName:="PivotTable11", DefaultVersion:=6
Sheets("Sheet32").Select
Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable11").PivotFields("AM")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable11").PivotFields("BM")
.Orientation = xlRowField
.Position = 2
End With
With ActiveSheet.PivotTables("PivotTable11").PivotFields("Due/Idle Loc")
.Orientation = xlRowField
.Position = 3
End With
End Sub