Change calculated field in pivot based on option button

dancing-shadow

New Member
Joined
Dec 4, 2011
Messages
24
Morning - hoping this is a quick and easy fix!

I have an option button on the same sheet as a pivot table. The pivot table has two similar calculated fields currently

Within SLA % = 'Within SLA' / Projects
Outside SLA % = 'Outside SLA' / Projects

What I want is to toggle both calculated formula between /Projects and /Jobs by clicking the option button.

The code I currently have is not working:
Code:
With ActiveSheet.PivotTables("PivotTable5")
    .CalculatedFields("Within SLA %").StandardFormula = "='Within SLA'/Jobs"
    .CalculatedFields("Outside SLA %").StandardFormula = "='Outside SLA'/Jobs"
End With

Am I going about this the right way or is there a better option?

TIA :)
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi, I am not clear as to why you need an option button to accomplish this, as this can be achieved within the functionality available within the PIVOT table itself on the basis that the "Within SLA %" & "Outside SLA %" are fields within your base dataset?
 
Upvote 0
The file is a template to produce a report. The sheets with pivots are stripped out and sent to the client, so they a dashboard type view with the option button to change the view on the pivots to see the figures at job or project level without needing to change formula's themselves (as they simply don't have the knowledge to do so!)
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,623
Latest member
Techenthusiast

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