Reference to external file / shorten its name

Nachtklavier

New Member
Joined
Mar 4, 2023
Messages
4
Office Version
  1. 2013
Platform
  1. Windows
Hi there,

I am using formulas in workbook A to get data from workbook B.
Within the formulas the name of Workbook B as well as the object name are displayed:
Excel Formula:
=vlookup( [@number], 'LongFileNameWithExtension'!TableName[#Data], ... )

My question is: (how) can the "LongFileName" be replaced with something more short, e.g. a reference in workbook A called "RefData", which contains the long file name?
My goal is to keep the formulas as short and clean as possible.

Thank you for any suggestion.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
VBA Code:
Dim ShortName as String
ShortName = TheFilePathAndFileNameString

       =vlookup( [@number], ShortName, ... )
 
Upvote 1
Hi @awoohaw,

Thank you very much for your lightning fast answer.
Is VBA the only way to solve this? I should have mentioned that VBA is not allowed to be used.

Thanks.
 
Upvote 0
no, i misread your first post, i thought it was vba statement

in a cell (say B4) put in the filepathNameExt of the file
then in your vlookup formula put $B$4 in your argument that had the longfilename. but a file name is not a range.
the 2nd argument of VLOOKUP should be a range of some sort.
 
Upvote 0
Will the other workbook be open?
 
Upvote 0
In that case you can use Indirect like
Excel Formula:
=vlookup( [@number],INDIRECT("'"&B1&"'!TableName[#Data]"), ... )
 
Upvote 1
Solution
@Fluff Thank you, this is indeed the preferred solution. Right after @awoohaw's reply I was thinking into that very direction.
Btw: Is there any chance to use something similar with Pivot tables (without VBA)? Or is this always kind of hard-coded?
 
Upvote 0
I know nothing about Pivots so cannot answer that.
 
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,172
Members
449,071
Latest member
cdnMech

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