PDA

View Full Version : unable to set the currentpage property of pivot in vba



kevvukeka
06-18-2013, 03:24 AM
I have a pivot. which has a report filter at it top. I am trying to loop change this filter through variable. But I am unable to do. if the variable is numeric its working fine, but now I am using string variable.
the variable name is "providername".

I tried these below codes but no works. the pivot remains unchanged. can someone show me where is going wrong.

1.ActiveSheet.PivotTables(1).PivotFields("Provider Name").CurrentPage = ProviderName.

2.Set PT = Sheets("Sheet2").PivotTables(1)
Set pf = PT1.PageFields(1)
pf.CurrentPage = ProviderName


3.With ActiveSheet.PivotTables("Summary_Report").PivotFields("Provider Name")
.ClearAllFilters
.PivotFilters.Add Type:=xlCaptionEquals, Value1:=ProviderName
End With


Thanks in advance...