Automating a formula using a pivot table and vba

K0D54

New Member
Joined
Aug 28, 2022
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Hello. I am trying to automate a formula using a pivot table and vba. As you can see in the image, there are several company names will change as well as the year and amounts but the supplies and tax categories will remain the same. I want to have a designated area like below each pivot table where I can run a macro to search the pivot table and come up with a formula similar to

=GETPIVOTDATA("totals",$A$3,"Year",2019,"company","pizza co","cost type","tax")/GETPIVOTDATA("totals",$A$3,"Year",2019,"company","pizza co","cost type","supplies")

where the tax is divided by the salary and then formatted as a percent.

I want to ensure the formula is run for each company and put in the correct place for the corresponding year. Is this possible, or would it be better to use the data sheet to automate the formula?

Thank you for any assistance!
 

Attachments

  • 2024-07-13_15-44-18.png
    2024-07-13_15-44-18.png
    30.2 KB · Views: 11

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,224,813
Messages
6,181,114
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