Update Pivot Field Using Macro

CBROWN1

New Member
Joined
Sep 28, 2009
Messages
43
Hi All-

I want to update the selected fields in multiple pivot tables based on cell contents but can't seem to get the macro right.

So for example one of the fields is "Year". I want the pivot tables to be limited to data that matches the value held in Sheet 1 Cell A1 (e.g. 2010).

Is there a simple piece of code that will do this?

Thanks in advance,
Cat
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi Cat,

This post might help.

http://www.mrexcel.com/forum/showthread.php?t=583204

If you copy the Filter_PivotField function shown in that thread into the same VBA module with the Sub below,
it should do what you describe.

Edit MyPivotTableSheet and MyPivotTable1 to match your names.
Code:
Sub Filter_ItemListInRange()
    Filter_PivotField _
        pvtField:=Sheets("MyPivotTableSheet") _
            .PivotTables("MyPivotTable1").PivotFields("Year"), _
            varItemList:=Application.Transpose(Sheets("Sheet1").Range("A1"))
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

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