PC Review


Reply
Thread Tools Rate Thread

Changing the CurrentPage items in a Pivot Table

 
 
John
Guest
Posts: n/a
 
      30th Sep 2008
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



 
Reply With Quote
 
 
 
 
Daniel.C
Guest
Posts: n/a
 
      30th Sep 2008
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
>
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error setting pivot table CurrentPage to nonexistent value Jim Microsoft Excel Crashes 0 8th May 2008 10:47 PM
Pivot Table Programing Help (Selecting Pivot Items) =?Utf-8?B?TWFuaXNoIEphaXRseQ==?= Microsoft Excel Programming 0 25th May 2007 12:38 PM
Retrieving pivot items for pivot table value cells without using PivotCell Casey Microsoft Excel Programming 0 20th Apr 2006 10:46 PM
PivotTable Pivot Fields CurrentPage lcdmjnd@gmail.com Microsoft Excel Programming 0 8th Sep 2005 06:01 PM
Changing a pivot table field items to current database Pete Straman Straman via OfficeKB.com Microsoft Excel Programming 4 22nd Feb 2005 04:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:21 PM.