spreadsheet Links

Peter100

Well-known Member
Joined
Apr 21, 2002
Messages
765
I have a workbook named Master.xls which is a master template.
I have workbooks for each month named JanData.xls - Dec.xls

I want to link the data from cell A1 in JanData.xls into cell A1 of
Master.xls which is simple enough.

The link would look like ='[JanData.xls]Sheet1'!$A$1

But what I want to be able to do is replace the [JanData.xls] part of the link
with a cell reference in Master.xls which would be a text entry so that the link
could be changed to read from FebData.xls - MarData.xls etc as desired.

Anyone any Ideas ?
 
No need to be sorry, we can lick this.

Not Chris' forte per his post:

ahh, yes, ermmm, physically opening a file based on a cell content needs some VBA coding
, and this means a different type of genius....

Which code did you try (see my last post)? Do prefer a set up which requires opening the workbook or one that works with closed workbooks?

Does B1 Chris' formula? It's possible we can get this to fire but vba code will be essential one way or another.

_________________
Cheers,<font size=+2><font color="red"> Nate<font color="blue">O</font></font></font>
wave.gif

This message was edited by nateo on 2002-05-13 14:57
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hi Nate
No error messages

Chris's code is in B4 and I've changed the references in the VB accordingly (remember Chris's code is going to be in a range of cells on each sheet)

Don't mind if the workbook is opened automatically on selection or I suppose it would be better if it worked with closed workbooks. depends upon the complexity of the code required.
This message was edited by Peter100 on 2002-05-13 15:05
 
Upvote 0
You only need to reference one of the formulae, so I'd use this:<pre>
Private Sub Worksheet_Change(ByVal Target As Range)
'Macro recorded by Nate
Dim o As Integer, s As Integer
Dim z As String
If Target.Address = "$A$1" Then
o = InStr([b4].Formula, "[")
s = InStr([b4].Formula, "]")
ChDrive ("C") 'hardcode your target drive letter
ChDir ("C:tempxltest") 'hardcode your target file path
z = Application.Substitute(Mid([b4].Formula, _
o + 1, s - 1 - o), ".xls", "") & ".xls"
Workbooks.Open [a1].Value & Application.Substitute(z, _
"""&$A$1&""", "")
End If
End Sub</pre>

If you get no reaction from this, go into a normal module (in any workbook) and run the following code:<pre>
sub st()
application.enableevents = true
end sub</pre>

Then try again. Hope this helps. If not let us know.

_________________
Cheers,<font size=+2><font color="red"> Nate<font color="blue">O</font></font></font>
wave.gif

This message was edited by NateO on 2002-05-13 15:06
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,114,002
Members
448,543
Latest member
MartinLarkin

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