Create formula from cell value

henryg

Board Regular
Joined
Oct 23, 2008
Messages
113
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

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
62,240
Office Version
  1. 365
Platform
  1. Windows
How about
Excel Formula:
=XLOOKUP(A7,indirect("'"&TEXT(K1,"mmmyy")&"'!A7:A21"),indirect("'"&TEXT(K1,"mmmyy")&"'!D7:D21"))
 

etaf

Well-known Member
Joined
Oct 24, 2012
Messages
4,866
Office Version
  1. 365
Platform
  1. MacOS
Edit.,
Post while I was composing

perhaps an indirect()
=XLOOKUP(A7,INDIRECT("'"&TEXT(K1,"MMMYY")&"'!A7:A21"),INDIRECT("'"&TEXT(K1,"MMMYY")&"'!D7:D21"))
 
Solution

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
62,240
Office Version
  1. 365
Platform
  1. Windows
Glad we could help & thanks for the feedback.
 

Forum statistics

Threads
1,141,049
Messages
5,703,942
Members
421,321
Latest member
blusky4

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
Top