I have a ppivot table in Excel 2007 which has a Label Filter on one of the date fields for "Greater then or Equal to" a certain date. I have a macro that updates the source of the pivot table and refreshes it. After the refresh the table comes up empty and I have to go to the filter and just click OK (the filter value is still defined there) to see the data in the pivot. Why doesnt the filter get applied after the refresh?
Here is my code snippet:
Set c = ThisWorkbook.Connections.Item("Connection1")
c.OLEDBConnection.CommandText = "exec DB1.dbo.sp_GetnewData"
c.Refres
For Each pivot In ThisWorkbook.Worksheets("Sheet1").PivotTables
pivot.RefreshTable
Next