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: 8

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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