Pivot Table (PivotField) Macro

br0nc0boy

New Member
Joined
Mar 12, 2009
Messages
27
Hi, I have basically two tabs.

- Sheet1: Has dropdown of all the managers
- Sheet2: Has a bunch of pivots (all pivots are filtered by managers)

Once you dropdown to a manager, macro will run and what it will do is change all the pivots to that person's name. Now my macro is kind of long (but it works) but it won't capture any new pivots that are going to be added in the future, so I am wanting to use Dim but unfortunately I have no VBA background and wasn't able to do this on my own and hoping someone can help me.

My code is as follow:

Sub ChangeASMs()
Sheets("Data").PivotTables("PivotTable1").PivotFields("ASM").CurrentPage = _
Sheets("Dropdown").Range("I3").Value
Sheets("Data").PivotTables("PivotTable2").PivotFields("ASM").CurrentPage = _
Sheets("Dropdown").Range("I3").Value
Sheets("Data").PivotTables("PivotTable3").PivotFields("ASM").CurrentPage = _
Sheets("Dropdown").Range("I3").Value
Sheets("Data").PivotTables("PivotTable4").PivotFields("ASM").CurrentPage = _
Sheets("Dropdown").Range("I3").Value
Sheets("Data").PivotTables("PivotTable5").PivotFields("ASM").CurrentPage = _
Sheets("Dropdown").Range("I3").Value
Sheets("Data").PivotTables("PivotTable6").PivotFields("ASM").CurrentPage = _
Sheets("Dropdown").Range("I3").Value
Sheets("Data").PivotTables("PivotTable7").PivotFields("ASM").CurrentPage = _
Sheets("Dropdown").Range("I3").Value
Sheets("Data").PivotTables("PivotTable9").PivotFields("ASM").CurrentPage = _
Sheets("Dropdown").Range("I3").Value
Sheets("Data").PivotTables("PivotTable10").PivotFields("ASM").CurrentPage = _
Sheets("Dropdown").Range("I3").Value
Sheets("Data").PivotTables("PivotTable1").PivotFields("Corp Name").AutoSort _
xlDescending, "Sum of 90 Day PVA Total"

End Sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,215,674
Messages
6,126,144
Members
449,294
Latest member
Jitesh_Sharma

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