Create formula from cell value

henryg

Board Regular
Joined
Oct 23, 2008
Messages
145
Office Version
  1. 365
Platform
  1. Windows
I have a cell with the formula

=XLOOKUP(A7,'Dec20'!A7:A21,'Dec20'!D7:D21)

which I want to change so that the Dec20 part of the formula is derived from a month referenced in another cell eg K1 with 31/01/21

I can get 'Jan21'! via ="'"&TEXT(K1,"mmmyy")&"'!" but I can't manage to successfully concatenate that into the formula to replace 'Dec20'!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
How about
Excel Formula:
=XLOOKUP(A7,indirect("'"&TEXT(K1,"mmmyy")&"'!A7:A21"),indirect("'"&TEXT(K1,"mmmyy")&"'!D7:D21"))
 
Upvote 0
Edit.,
Post while I was composing

perhaps an indirect()
=XLOOKUP(A7,INDIRECT("'"&TEXT(K1,"MMMYY")&"'!A7:A21"),INDIRECT("'"&TEXT(K1,"MMMYY")&"'!D7:D21"))
 
Upvote 0
Solution
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,782
Messages
6,121,532
Members
449,037
Latest member
tmmotairi

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