View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
John John is offline
external usenet poster
 
Posts: 2,069
Default Changing the CurrentPage items in a Pivot Table

Hello,

I have an already generated Pivot Table which i would like to amend the
CurrentPageitems programmatically.

I have a list of fields in a tab. I am able to select fields in this list
that i would then like to build into my Pivot table as CurrentPage items.
Using:
For i = 1 To MyRange.Rows.Count

If Len(Application.WorksheetFunction.Index(MyRange, i, 2)) 0 Then
MySelection = Application.WorksheetFunction.Index(MyRange, i, 1)
ActiveSheet.PivotTables("PivotTable1").PivotFields ("" &
MySelection & "").CurrentPage = "(All)"
End If

Next

I get the runtime error 1004 and the message "Unable to get the PivotFields
Property of the Pivot Table Class".

Guess what this comes down to is their is a much better way of doing this.
Would anyone be able to help me with this please?

Thanks
John