I have three macros. They were recorded separately, first one setups fine, the 2nd and 3rd appears too. The second gives me the error in my title "Unable to get the pivotfields property of the pivottable class"
Sub PivotTable2()
'
'
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"DCMR!R1C1:R725C14", Version:=6).CreatePivotTable TableDestination:= _
"'Sheet1'!R1C5", TableName:="PivotTable2", DefaultVersion:=6
Sheets("Sheet1").Select
Cells(1, 5).Select
With ActiveSheet.PivotTables("PivotTable2").PivotFields("Date Reviewed")
.Orientation = xlPageField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable2").PivotFields("Location")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable2").PivotFields("Error Type")
.Orientation = xlRowField
.Position = 2
End With
Range("F9").Select
ActiveSheet.PivotTables("PivotTable2").PivotFields("Error Type").PivotFilters. _
Add2 Type:=xlTopCount, DataField:=ActiveSheet.PivotTables("PivotTable2"). _
PivotFields("Count of Error Type"), Value1:=3
End Sub
Bookmarks