Dynamic reference to external workbooks in formula's

maartenfct

New Member
Joined
Jan 2, 2017
Messages
9
Hi All,

I was wondering if there's a method to achieve the following. I work with a large number of externally provided fixed format workbooks. From all those workbooks I need a number of values which are in the same exact cells. See table below for an example of what I would like to achieve. Cell B1 has a reference to one of the external workbooks. But rather than having to manually change the workbook name from in this case test1 to test2, I would like a function which reads the text in column A and inserts the text in the formula so it automatically changes the formula to the correct directory. To have it as efficient as possible, the link to column A should be a drag down function as well if that's possible.

AB
1test1
='C:\Users\...[test1.xlsx]10.Source-Disposition'!$B$26
2test2='C:\Users\...["A2".xlsx]10.Source-Disposition'!$B$26
3test3
4test4
5test5

<tbody>
</tbody>

Hopefully you are able to help!

Cheers,
Maarten
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hi

The INDIRECT function could be a solution, but the workbooks would need to be open.
The code below does it:

Code:
Sub CreateFormulas()
Const Begin = 100
Dim i%
For i = Begin To Range("a" & Rows.Count).End(xlUp).Row
    Cells(i, 2).Formula = "='c:\pub\[" & Cells(i, 1) & ".xlsm]disposition'!$b$26"
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,514
Messages
6,125,265
Members
449,219
Latest member
daynle

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