PC Review


Reply
Thread Tools Rate Thread

Change Pivot Table Page Value

 
 
kernel
Guest
Posts: n/a
 
      19th May 2010
I have looked through the other posts on the subject and the combination of
my low skills in VB and the other solutions not exactly covering my situation
means I still need to ask for help.

Scenario:

Worksheet a = "Scorecard"
FieldName = "CustomerNumber"

Worksheet b = "Products Resume"
PivotTable = "PivotTable2"
PivotTable Page Field = "Account Number"

When CustomerNumber value on worksheet "Scorecard" is changed I need the
Pivot Table Page field "Account Number" to use this value to filter the pivot
table.

I found the below code which looks like it may be close to what I need but
my lack of VB knowledge meant I could not adapt it -

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("SelDept").Address Then
Me.PivotTables(1).PivotCache.Refresh
End If
End Sub

Help please...
 
Reply With Quote
 
 
 
 
Javed
Guest
Posts: n/a
 
      19th May 2010
On May 19, 5:27*am, kernel <ker...@discussions.microsoft.com> wrote:
> I have looked through the other posts on the subject and the combination of
> my low skills in VB and the other solutions not exactly covering my situation
> means I still need to ask for help.
>
> Scenario:
>
> Worksheet a = "Scorecard"
> FieldName = "CustomerNumber"
>
> Worksheet b = "Products Resume"
> PivotTable = "PivotTable2"
> PivotTable Page Field = "Account Number"
>
> When CustomerNumber value on worksheet "Scorecard" is changed I need the
> Pivot Table Page field "Account Number" to use this value to filter the pivot
> table.
>
> I found the below code which looks like it may be close to what I need but
> my lack of VB knowledge meant I could not adapt it -
>
> Option Explicit
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Target.Address = Range("SelDept").Address Then
> * * Me.PivotTables(1).PivotCache.Refresh
> End If
> End Sub
>
> Help please...



Option Explicit


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("SelDept").Address Then
Me.PivotTables(1).PivotFields("Account
Number").CurrentPage=Range("SelDept").Value
Me.PivotTables(1).PivotCache.Refresh
End If
End Sub

I have expected that Range("SelDept") avlue will decide the page of
pivottable.


 
Reply With Quote
 
kernel
Guest
Posts: n/a
 
      21st May 2010
Thanks for the response. Based on your suggestion and with my fields added
the code looks like this -

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("CustomerNumber").Address Then
Me.PivotTables(2).PivotFields("Account Number").CurrentPage =
Range("CustomerNumber").Value
Me.PivotTables(2).PivotCache.Refresh
End If
End Sub

.....but I get the error

"method 'PivotTables' of object '_Worksheet' failed

Any ideas?
 
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
How Do I Change Two Pivot Table Page Selections with VBA Code dmarsh Microsoft Excel Programming 1 28th Jul 2009 03:42 PM
Pivot Table - change page field help Opal Microsoft Excel Programming 23 16th Mar 2009 07:07 PM
Pivot Table Page Change Code PFLY Microsoft Excel Misc 1 16th May 2008 12:42 AM
Change Page Field in a Pivot Table and Print Chart + Data =?Utf-8?B?UGhpbGlwIEogU21pdGg=?= Microsoft Excel Programming 2 19th Feb 2007 04:13 PM
Pivot Tables - change flat file data from the pivot table Mark Microsoft Excel Worksheet Functions 2 18th Nov 2003 08:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:44 AM.