Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default reference file

I have this formula that works fine, is there a way to replace the file to
reference a cell, so that I can just change the file name in one cell rather
thn the many the formula appears in?

=IF(FILE'!$C4="","",'FILE'!$C4))
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default reference file

In your example FILE is a SHEET name rather than a file name, isn'it? If so,
sheet name being in A1
=INDIRECT(A1&"!C4")

Regards,
Stefi

€˛Miree€¯ ezt Ć*rta:

I have this formula that works fine, is there a way to replace the file to
reference a cell, so that I can just change the file name in one cell rather
thn the many the formula appears in?

=IF(FILE'!$C4="","",'FILE'!$C4))

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default reference file

Sorry, I removed the file path because it is very long - will this still work
to reference a full file path?

"Stefi" wrote:

In your example FILE is a SHEET name rather than a file name, isn'it? If so,
sheet name being in A1
=INDIRECT(A1&"!C4")

Regards,
Stefi

€˛Miree€¯ ezt Ć*rta:

I have this formula that works fine, is there a way to replace the file to
reference a cell, so that I can just change the file name in one cell rather
thn the many the formula appears in?

=IF(FILE'!$C4="","",'FILE'!$C4))

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default reference file

The function you'd want to use that's built into excel is =indirect(). But that
function returns an error if the sending workbook is closed.

If that's a problem, then Laurent Longre has an addin (morefunc.xll) at:
http://xcell05.free.fr/
or
http://xcell05.free.fr/morefunc/english/index.htm

That includes =indirect.ext() that may help you.

Miree wrote:

Sorry, I removed the file path because it is very long - will this still work
to reference a full file path?

"Stefi" wrote:

In your example FILE is a SHEET name rather than a file name, isn'it? If so,
sheet name being in A1
=INDIRECT(A1&"!C4")

Regards,
Stefi

€˛Miree€¯ ezt Ć*rta:

I have this formula that works fine, is there a way to replace the file to
reference a cell, so that I can just change the file name in one cell rather
thn the many the formula appears in?

=IF(FILE'!$C4="","",'FILE'!$C4))


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default reference file

Unfortunately not, in this case use =INDIRECT("["&A1&".xls]sheetname!C4")
but it works only if the referenced file is open.

If you want to change full path of a link then you need some VBA code like
this:

For testing I made a Data validation list for cell A1 containing possible
full paths.
E.g.
C:\work\int1.xls
C:\work\int2.xls
both should contain a sheet named sheet1.
1. Enter ='C:\work\[int1.xls]sheet1'!$C$4 in the result cell
2. Install this event macro:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "A1" Then
alinks = ActiveWorkbook.LinkSources(xlExcelLinks)
ActiveWorkbook.ChangeLink Name:=alinks(1), NewName:= _
Target, Type:=xlExcelLinks
End If
End Sub

Watch the reference in the result cell when selecting from drop down list of
A1.

Stefi


€˛Miree€¯ ezt Ć*rta:

Sorry, I removed the file path because it is very long - will this still work
to reference a full file path?

"Stefi" wrote:

In your example FILE is a SHEET name rather than a file name, isn'it? If so,
sheet name being in A1
=INDIRECT(A1&"!C4")

Regards,
Stefi

€˛Miree€¯ ezt Ć*rta:

I have this formula that works fine, is there a way to replace the file to
reference a cell, so that I can just change the file name in one cell rather
thn the many the formula appears in?

=IF(FILE'!$C4="","",'FILE'!$C4))

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get file reference using File System Object XP Excel Programming 3 December 18th 08 06:43 PM
Linking to another file using file reference typed cell Steven Excel Worksheet Functions 3 April 5th 08 03:15 AM
cross-reference data from one file to another file Zancouth Excel Discussion (Misc queries) 1 May 30th 06 11:25 AM
How do I reference external data from a file, file name found in . Clux Excel Discussion (Misc queries) 1 February 10th 05 10:52 PM
copy/paste from one file to another without file name reference slvrblt Excel Discussion (Misc queries) 4 February 6th 05 08:57 PM


All times are GMT +1. The time now is 09:12 AM.

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

About Us

"It's about Microsoft Excel"