Use cell data to change the formula of table cell reference

gberg

Board Regular
Joined
Jul 16, 2014
Messages
180
Office Version
  1. 365
Platform
  1. Windows
I have a table that has headers "Data", "2024", "2023" and "2022". I can use a formula =[@2022] that will result in 111. I want to be able to change the value in the "Data Reference" cell so when I change it to 2023 or 2024 it will return 777 or 555 respectively. I tried =INDIRECT("[@"&B1&"]") but get a #REF! error.

Any help would be appreciated

Data Reference2022
Data202420232022
=[@2022]​
555​
777​
111​
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Use the name of table:

varios 20ene2024.xlsm
ABCD
1Data Reference2023
2Data202420232022
3777555777111
Hoja3
Cell Formulas
RangeFormula
A3A3=INDIRECT("Table1[@"&B1&"]")
 
Upvote 0
A non volatile approach
Excel Formula:
=XLOOKUP(B1&"",Table1[[#Headers],[2024]:[2022]],Table1[@[2024]:[2022]])
 
Upvote 0
If you modify Fluff's formula to take in the entire table's columns that will save making it dependant on the current year headings
Excel Formula:
=XLOOKUP($B$1&"",Table1[#Headers],Table1[@])
PS: All options need B1 as absolute addressing $B$1.
 
Upvote 0
Solution
I'm always amazed at how smart people are on this board. Tanks to everyone for the help, Alex your solution works great. I can add additional years and don't need to rewrite all formulas for the added years! This is great!
 
Upvote 0

Forum statistics

Threads
1,215,086
Messages
6,123,043
Members
449,092
Latest member
ikke

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