Hello.
This should work if your fields are already defined as page fields.
--
Regards.
Daniel
"John" <(E-Mail Removed)> a écrit dans le message de news:
E43745A6-FB3F-4F76-9F5B-(E-Mail Removed)...
> 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
>
>
>