Dynamic formula via VBA?

TheWennerWoman

Active Member
Joined
Aug 1, 2019
Messages
303
Office Version
  1. 365
Platform
  1. Windows
Hello,

I hope someone can help; I'm sure this is fairly straightforward but I'm not that far along the VBA learning curve so please forgive me if this seems like a stupid question.

I have an Excel pivot table. I need to use VBA to add certain calculations to the far right of it (the spreadsheet is being used by people who just want to refresh it). However, the pivot table columns are months and so what works now won't work in November because there will be more columns.

The formula I am looking to add in is
Code:
=IFERROR(W2/L2,"")

and so on down the page.

This is currently going into X2. W2 is labelled PCT Total, L2 is labelled KPI Total.

Next month, however, the formula will be
Code:
=IFERROR(X2/M2,"")

and this will go into Y2.

So it's a constantly moving picture.

Any help greatly appreciated.
 
Last edited:

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.
Hello,

Following formula can help you determine the Target Column

Code:
=MONTH(TODAY())+16

And just underneath your formula could be

Code:
=OFFSET(A1,1,(MONTH(TODAY())+12))/OFFSET(A1,1,MONTH(TODAY())+1)

Hope this will help
 
Upvote 0
Solution

Forum statistics

Threads
1,224,817
Messages
6,181,144
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