Vba changing the reference column year

blaisjoel

New Member
Joined
Oct 28, 2016
Messages
30
I have a spreadsheet table that has columns for the last 10 years. Each new year, these columns are changed to add one year to it. My problem is that I have another workbook table referencing this table with each cell using a formula. I want to be able to change the formula so it references the correct column.

Here is a preview of what the formula looks like.

=LOOKUP(2,1/('ARTICULATED TRUCK AVERAGE HOURS YEARLY.xlsx'!ARTICULATEDTRUCK[2018]<>""),'ARTICULATED TRUCK AVERAGE HOURS YEARLY.xlsx'!ARTICULATEDTRUCK[2018])

Need to change the 2018 to 2019 in the formula.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Record a macro to use find and replace, that should pick up 2018 and replace with 2019. Then you have the code
 
Last edited:
Upvote 0
Solution
That's great thinking Trevor. Thanks.
I never noticed Excel gives me the ability to find and replace in formulas.
I did have another solution which would change my code to select last row in column address instead of last row from column header. I prefer using the header.
 
Upvote 0
Good to read you have a solution that works for you.
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,580
Members
449,039
Latest member
Arbind kumar

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