Update formula Col reference Macro

xcelnovice

Board Regular
Joined
Dec 31, 2011
Messages
81
Is there a way to use a macro to update a column a sum if or vlookup formula is pulling data from. Ex for a vlookup I have 12 mos of budget data in columns. In Feb I am pulling data from the 8th Col in the table. I'd like to run a macro that would update that number by 1 to pull Col 9 next month and Col 10 the following. It'd be similar with the sum of but increase from Col D to Col F etc. Thanks
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hi xcelnovice,

Are you sure you really need to do this with VBA? Here are some dynamic examples that work using worksheet functions to pick column number.


Excel 2007
ABCDEF
1JanFebMarAprMay
2Data 11418116800155781939312412
3Data 21520315498142161786313151
4Data 31247917368101041223419279
5Data 41915717592153801211616113
6
7FebFeb
8Data 11680016800
9Data 21549815498
10Data 31736817368
11Data 41759217592
Sheet3
Cell Formulas
RangeFormula
C7=B7
C8=VLOOKUP(A8, $A$2:$F$5, MONTH($C$7)+1, 0)
B8=INDEX($A$1:$F$5, MATCH($A8, $A$1:$A$5, 0), MATCH(B$7, $A$1:$F$1, 0))
 
Upvote 0
Using the same values and ranges here are two options


Excel 2007
D
7Mar
855278
955278
Sheet3
Cell Formulas
RangeFormula
D7=C7
D8=SUM(OFFSET(A1, 1, MATCH(D7, $B$1:$G$1, 0), 4, 1))
D9=SUM(INDEX($A$1:$F$5, 2, MATCH(D7, $A$1:$G$1, 0)):INDEX($A$1:$F$5, 5, MATCH(D7, $A$1:$G$1, 0)))
 
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,544
Members
449,316
Latest member
sravya

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