Indirect Syntax - Outside the workbook

itsrich

Board Regular
Joined
Apr 13, 2009
Messages
69
Office Version
  1. 365
Platform
  1. Windows
I am pullling data from multiple workbooks with multiple tabs. The file folder, file name, and tab all change, but the data is in the same place on all the spread sheets.

If I was on one tab I would use XLOOKUP(B5,'S:\2025 Purchasing\2.SPREADSHEETS\[Cycle Count 1 (Floor) 2025.xlsm]360 Products '!$D:$D,'S:\2025 Purchasing\2.SPREADSHEETS\[Cycle Count 1 (Floor) 2025.xlsm]360 Products '!$G:$G,"")

So I am choosing to use INDIRECT("'[&file name&".xlsm]"&tab name&"'!cell name")

Assume these are in column X:Z and rows 1:2

File FolderFileTab
S:\2025 Purchasing\2.SPREADSHEETSCycle Count 1 (Floor) 2025360 Products

Replacing the green text with INDIRECT("'CONCAT(X2,'\[',Y2,".xlsm]")'"&Z2&"'!$D:$D)

XLOOKUP(B5,'INDIRECT("'CONCAT(X2,'\[',Y2,".xlsm]")'"&Z2&"'!$D:$D),'S:\2025 Purchasing\2.SPREADSHEETS\[Cycle Count 1 (Floor) 2025.xlsm]360 Products '!$G:$G,"")

Excel sites an error and highlights this part of the formula "\[". The " and ' mix me up. I think I am close.

Thank you for your help.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Your formula should read:
VBA Code:
XLOOKUP(B5,"'"&X2&"\["&Y2&"]"&Z2&"'!D:D","'"&X2&"\["&Y2&"]"&Z2&"'!G:G","")
Even if this is correct, for this to work the workbooks in question must be open in Excel
 
Upvote 0
You are correct, it only works when both workbooks are open. I am collecting data from 15 spreadsheets across 160 tabs.

One XLookUp with two similar INDIRECT functions allow me to use one formula to reach all the info.

My issue is getting the syntax of the formula correct. (Is Syntax the correct term here)

XLOOKUP(B5,"'"&X2&"\["&Y2&"]"&Z2&"'!D:D","'"&X2&"\["&Y2&"]"&Z2&"'!G:G","") works, BUT "&X2&"\["&Y2&"]"&Z2&" returns text. XLookUp does not recognize text. INDIRECT makes text formula friendly.
 
Upvote 0
You don't want the CONCAT inside the quotes as you had it originally.

=XLOOKUP(B5,INDIRECT("'"&X2&"\["&Y2&".xlsm]"&Z2&"'!$D:$D"),'S:\2025 Purchasing\2.SPREADSHEETS\[Cycle Count 1 (Floor) 2025.xlsm]360 Products '!$G:$G,"")
 
Upvote 0
I apologize, I was so much focussed on getting the text concatenation right that I forgot to include the INDIRECT function in my example :)
 
Upvote 0
I should have done this from the start (I didn't think work would let me install Xl2bb).

Goal, develop a formula that will using the info in Master - rework 2024.09.10.xlsx to find the price in Cycle Count 1 (Floor) 2025.xlsm
  • Column B is the the search criteria
  • Colunm C, D, and E are the locations
    • Multiple File folders in column C (this may not be usable, INDIRECT may not be able to use this)
    • Multiple Files in column D
    • Multiple Tabs/Sheets in column E (I only supplied one TAB)
    • I am collecting data from 15 spreadsheets across 160 tabs in multiple directories
  • The results will be in column F
You can see the formula in F5 works. I am avoiding using this because I don't want to code that many formulas.

I have been attempting to make INDIRECT do the work, but I can't figure it out.

I think I am stuck on the signle and double quotes. I am so close, TY for your help!

Master - rework 2024.09.10.xlsx
ABCDEF
2FR #Vendor PNFile FolderFileTabVendor ID Cycle Count 1 (floor) 2025
3F100309670DT-SUPPORTUnkownUnkownUnkown
4F100270595540G2S:\2025 Purchasing\2.SPREADSHEETSCycle Count 1 (Floor) 2025360 Products
5F10050365045210765S:\2025 Purchasing\2.SPREADSHEETSCycle Count 1 (Floor) 2025.xlsxADORN23.21
6F10040503445210772S:\2025 Purchasing\2.SPREADSHEETSCycle Count 1 (Floor) 2025ADORN#REF!
7F1003813312259-180S:\2025 Purchasing\2.SPREADSHEETSCycle Count 1 (Floor) 2025BOYD INDIANA
8F1002405482259-96S:\2025 Purchasing\2.SPREADSHEETSCycle Count 1 (Floor) 2025BOYD INDIANA
9F1000668523840RBKS:\2025 Purchasing\2.SPREADSHEETSCycle Count 1 (Floor) 2025D & W
10F1004245563940BKS:\2025 Purchasing\2.SPREADSHEETSCycle Count 1 (Floor) 2025D & W
11F1003492553U115S:\2025 Purchasing\2.SPREADSHEETSCycle Count 1 (Floor) 2025H.B FULLER
12F1003182393U316S:\2025 Purchasing\2.SPREADSHEETSCycle Count 1 (Floor) 2025H.B FULLER
13F100349578AERO 5324PS:\2025 Purchasing\2.SPREADSHEETSCycle Count 1 (Floor) 2025HAHN SYSTEMS, LLC
14F100358023AEROSMITH 5323HPSTS:\2025 Purchasing\2.SPREADSHEETSCycle Count 1 (Floor) 2025HAHN SYSTEMS, LLC
Sheet4 (2)
Cell Formulas
RangeFormula
F5F5=XLOOKUP(B5,'[Cycle Count 1 (Floor) 2025.xlsm]ADORN'!$D:$D,'[Cycle Count 1 (Floor) 2025.xlsm]ADORN'!$F:$F)
F6F6=XLOOKUP(B6,INDIRECT("'["&J6&".xlsm]"&K6&"'!$D:$D"),INDIRECT("'["&J6&".xlsm]"&K6&"'!$F:$F,"""))


Cycle Count 1 (Floor) 2025.xlsm
ABCDEFG
1QTY ORD'DF100 #PART #DESCRIPTIONPRICEEXT. PRICE
2F10027585145216818MP 1/8X48X96 LONDON ASH 45G LAUAN$ 18.02$ -
3F10027581445217324MP 1/8X48X108 LONDON ASH 45G LAUAN G2S$ 29.62$ -
4F10027585045216819MP 1/8X48X96 AMERICANO 45G LAUAN$ 16.63$ -
5F10027581345217330MP 1/8X48X108 AMERICANO 45G LAUAN G2S$ 29.63$ -
6F10041374745210798MP 1/8X48X96 TARTAN FOSSIL .004 LAUAN$ 17.67$ -
7F10040503445210772MP 1/8X48X96 MONET RIDGE EXPRESS .004 LAUAN$ 18.73$ -
8F10041086145210774MP 1/8X48X108 MONET RIDGE EMPRESS .004 LAUAN L1S -$ 28.22$ -
9F10041374545210795MP 5/32X47-3/4X100 - MALONEY MIST LAUAN *CEILING* PHIL$ 28.46$ -
10F10041621845211256MP 5/32X48X 96 x 2.7- MALONEY MIST LAUAN *CEILING* DUANE$ 22.27$ -
11F10041374645210796MP 2.7MMX48X116 MONET RIDGE EMPRESS .004 AZDEL PUR$ 27.04$ -
12F100503650452107652.7MM 48" X 83.875" MONET RIDGE EMPRESS AZDEL$ 23.21$ -
13F10050365145212045MP 2.7MMX48X119 MONET RIDGE EMPRESS .004 AZDEL L1S$ 28.62$ -
14F10050365245212044MP 2.7MMX48X114 MONET RIDGE EMPRESS .004 AZDEL L1S 9 $ 26.87$ -
ADORN (2)
 
Upvote 0
If J6 already contains the extension .xlsm, there is no need to add that in the formula. But your table doesn't show column J so we have no way of knowing

Excel Formula:
=XLOOKUP(B6,INDIRECT("'["&J6&"]"&K6&"'!$D:$D"),INDIRECT("'["&J6&"]"&K6&"'!$F:$F,"""))
 
Upvote 1
Jan Karel, Thank you. Thank you on two levels! First, this formula works! Second, for pointing out how to improve!

I missed the file extension! I may have had the formula correct in my efforts, but I had not even considered I need to add the file extension to the formula or the data!

Thank you for pointing out the file is a .xlsm and not .xlsx.

I need to correct the formula
Excel Formula:
=XLOOKUP(B6,INDIRECT("'["&J6&"]"&K6&"'!$D:$D"),INDIRECT("'["&J6&"]"&K6&"'!$F:$F"),"")
  • The INDIRECT part of the formula (Jan Karel's part!) is correct
  • Compare the 3rd part of the XLookUp and you see the difference.

I have finished the formula a 3rd XLookUp statement
Excel Formula:
=XLOOKUP(B39,INDIRECT("'["&J39&"]"&K39&"'!$D:$D"),INDIRECT("'["&J39&"]"&K39&"'!$F:$F"),CONCAT("No price on ",K39))

Again, thank you Jan Karel!
 
Upvote 0
Solution

Forum statistics

Threads
1,221,417
Messages
6,159,789
Members
451,589
Latest member
Harold14

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