A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Links and Linking
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Approach Linked documents via INDIRECT



 
 
Thread Tools Display Modes
  #1  
Old December 10th, 2004, 12:11 PM
Johannes
external usenet poster
 
Posts: n/a
Default Approach Linked documents via INDIRECT

I try to approach an external document, defined in cell A1 in cell B2

A1 := '[File1.xls]Sheet1!$A$1
A2 := =INDIRECT(A1)

This works perfectly if File1.xls is open, but gives #REF! is File1.xls
isn't open.

Is there a way I can link to a file defined in a cell, without that file
being opened

(in the real problem I link to a file with a specific element in the name
that changes frequently. I want to define the exact file to link to in the
"master" excel sheet).

Thanks,

Johannes


  #2  
Old December 10th, 2004, 01:12 PM
Bill Manville
external usenet poster
 
Posts: n/a
Default

Johannes wrote:
A2 := =INDIRECT(A1)

This works perfectly if File1.xls is open, but gives #REF! is File1.xls
isn't open.


Correct. That is a feature of INDIRECT

Is there a way I can link to a file defined in a cell, without that file
being opened

Not without running a macro to change the link source(s) for you.
For example you could have a Worksheet_Change procedure that detects a
change in A1 and changes the link source to that file. Something like:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Intersect(Target, Me.Range("A1")) Is Nothing Then Exit Sub
If IsEmpty(Me.Range("A1")) Then Exit Sub
If Dir(Me.Range("A1"))="" Then
MsgBox "File " & Me.Range("A1") & " not found"
Exit Sub
End If
ThisWorkbook.ChangeLink ThisWorkbook.LinkSources(xlExcelLinks)(1),
Me.Range("A1")
End Sub

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - respond to newsgroup

  #3  
Old December 10th, 2004, 02:36 PM
Johannes
external usenet poster
 
Posts: n/a
Default

Thanks Bill,

Does not happen too often, but every now and then i am disappointed by
Excel.

Thanks for the work-around though.

Johannes

"Bill Manville" schreef in bericht
...
Johannes wrote:
A2 := =INDIRECT(A1)

This works perfectly if File1.xls is open, but gives #REF! is File1.xls
isn't open.


Correct. That is a feature of INDIRECT

Is there a way I can link to a file defined in a cell, without that file
being opened

Not without running a macro to change the link source(s) for you.
For example you could have a Worksheet_Change procedure that detects a
change in A1 and changes the link source to that file. Something like:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Intersect(Target, Me.Range("A1")) Is Nothing Then Exit Sub
If IsEmpty(Me.Range("A1")) Then Exit Sub
If Dir(Me.Range("A1"))="" Then
MsgBox "File " & Me.Range("A1") & " not found"
Exit Sub
End If
ThisWorkbook.ChangeLink ThisWorkbook.LinkSources(xlExcelLinks)(1),
Me.Range("A1")
End Sub

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - respond to newsgroup



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reports linked to word documents Jaime Setting Up & Running Reports 0 November 11th, 2004 12:32 AM
Can slide change when linked .JPG changes while presentation is running? Charlie Spencer Powerpoint 10 November 3rd, 2004 03:50 AM
INDIRECT formula question wardcanoe Worksheet Functions 2 December 30th, 2003 10:31 PM
Linked Documents shartman Links and Linking 1 September 17th, 2003 10:55 AM


All times are GMT +1. The time now is 05:25 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.