Okay, I really am frustrated right now. For the past hour or so I have been trying to get data from a simple Pivot. I cannot get it to work.
My really simple code:
Sub getXXFromPivot()
Dim test As PivotTable
Set Sheet1 = ActiveWorkbook.Sheets("Sheet5")
Set test = Sheet1.PivotTables("PivotTable1")
Set test2 = test.ClearAllFilters
MsgBox test2
End Sub
I am trying to use the "GetPivotData" method to get data, but no matter what I use after test. (ClearAllFilters was just a test) I always end up with error 1004. What is my mistake here? I cannot figure it out.
"PivotTable1" definitely exists. I can MsgBox test and get "PivotTable1" back.
test.ClearAllFiltersinstead ofSet test2 = test.ClearAllFilters. Also, the message in the message box has to be a string, whichtestis not. Also you should declareSheet1with a different name.1004? This codetest2 = test.ClearAllFiltersshould return "type mismatch" error.