Use cell data to change the formula of table cell reference

gberg

Board Regular
Joined
Jul 16, 2014
Messages
205
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

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
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,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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