I am getting an error on the following code: Application or Object Defined Error.
I just cannot seem to get it working??? Any ideas what the issue is?
The pivot table on the worksheet is surrounded by other data so I need to have it filter only for a three month period. I cannot clear the filters else it will overwrite data on the right due to 12 months. Even after recording a macro to filter, then run the recorded code, it bombs out with the same error?
Code: Select all
Dim myD1 As String, myD2 As String, MthCount As Integer
myD1 = Range("MAPSSD").Value
myD2 = Range("MAPSED").Value
MthCount = 12
Sheets("MAPS Report").PivotTables("AppCount").PivotFields("Date").PivotFilters.Add _
Type:=xlDateBetween, Value1:=myD1, Value2:=myD2