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

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
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,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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