Updating PIVOT table

scotball

Active Member
Joined
Oct 23, 2008
Messages
375
Hey,

So here's the latest problem...

I have created a dashboard based on a number of pivot tables. (Using GETPIVOTDATA tags)

One of the fields in the Dash tab is Week which is a drop down menu of 1-13. (GLA Dash C3)

I have two pivot tables in seperate tabs. (BottomQuartile1 and BottomQuartile2) both have Week as Report Filter.

At the moment when I change the week in Dash from 4 to 5 i have to manually go into the two BottomQuartile tabs and alter the week to match.

Is there anyway I can automate this process so that when i update the week in Dash it will update the Week in the other two tabs?

Thanks,
Lee
 
Last edited:
I pasted the code into the sheet and changed the value in C3 to test.

Run-time error '1004':
Application-defined or object-defined error

Worksheets("BottomQuartile1").PivotTables("BQ_Pivot1").PageFields(1).CurrentPage = Target.Text

Any ideas?
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Should i be referencing which field in the Pivot i want to update?

If so, how? :)

Thanks again for all your help...

LP
 
Upvote 0
I tested the code before I posted it. What do you have in your dropdown and is it the same as the list in the pivot table's page field?
 
Upvote 0
It's the same as far as i can see.

The week in the pivot is pulled from a rawdata sheet and the week in the dropdown is simply a list of numbers, 1-13 which would align to the pivot.

Thanks,
Lee
 
Upvote 0
Code:
Sub change_pagefield()
'
' change_pagefield Macro
'
'
    ActiveSheet.PivotTables("BQ_Pivot1").PivotFields("Week").ClearAllFilters
    ActiveSheet.PivotTables("BQ_Pivot1").PivotFields("Week").CurrentPage = "2"
End Sub
 
Upvote 0
Updated the code in the GLA Dash sheet to see if that was what was wrong (just guessing obviously):

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address <> "$C$3" Then Exit Sub
    Worksheets("BottomQuartile1").PivotTables("BQ_Pivot1").PivotFields("Week").CurrentPage = Target.Text
    Worksheets("BottomQuartile2").PivotTables("BQ_Pivot2").PivotFields("Week").CurrentPage = Target.Text
End Sub

And then ensured all of the week formatting is set to General.

I set the week in BQ1 to 2 and in BQ2 to 1. Then I changed the GLA Dash week from 4 to 5 and nothing happened... :S
 
Last edited:
Upvote 0
That should work. With the code below do you get a message when you change the week?

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address <> "$C$3" Then Exit Sub
    MsgBox Target.Value
    Worksheets("BottomQuartile1").PivotTables("BQ_Pivot1").PivotFields("Week").CurrentPage = Target.Text
    Worksheets("BottomQuartile2").PivotTables("BQ_Pivot2").PivotFields("Week").CurrentPage = Target.Text
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,563
Messages
6,125,550
Members
449,237
Latest member
Chase S

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top