Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default Formula to find filename

This is tough to do with a worksheet function because it is possible that
folders in the path could also contain the . symbol as part of their name,
along with the multiple \ symbols you expect.

But if you'll revisit that other workbook and put the entries (I presume
there's going to be more than one?) into the format returned by the CELL
function, that is, as:
C:\MY Files\Media\[Test.doc]
then you can modify Gary's offered formula to something like this (remember,
one long entry - not actually broken up as the editor here is no doubt going
to do)

=MID('[File B.xls]OtherWBSheet'!$A$1,FIND'[File
B.xls]OtherWBSheet'!$A$1)+1,FIND("]",'[File
B.xls]OtherWBSheet'!$A$1)-FIND("[",'[File B.xls]OtherWBSheet'!$A$1)-1)

If you need to keep the entries in File B in their current form (no
brackets), then add another column with them in that format for use in this
workbook to find them?

------------
Another option would be to use a User Defined Function that uses the VB
InstrRev() function to extract the right portion beyond the last \ symbol.

The function would look like this:
Function GetForeignFilename(anyPath As String) As String
GetForeignFilename = Right(anyPath, Len(anyPath) - _
InStrRev(anyPath, "\"))
End Function

and in your worksheet you would call it as:
=GetForeignFilename('[File B.xls]OtherWBSheet'!$A$1)

"Kevin" wrote:

Hi

I have a written the file path of File A in a cell of another spreadsheet,
say File B. The file path would be written as below
C:\MY Files\Media\Test.doc

I need a excel cell formula which can return the name of the
file (ie "Test.doc") no matter how many directories or the lenght of the
address. Note Cell("filename",a1) does not help me because this returns the
path of the existing spredsheet. Seems I need a way to find where the last
"\" is in the file path

any ideas

thanks
--
Kevin


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
Formula to find filename Kevin Excel Discussion (Misc queries) 3 August 2nd 07 10:12 PM
Using Range().Formula with a Filename & Path BJTex Excel Discussion (Misc queries) 1 November 11th 06 02:49 AM
Filename in a formula generated automatically? helptildette Excel Discussion (Misc queries) 1 July 15th 06 12:20 AM
set filename to <filename-date on open bob engler Excel Worksheet Functions 2 July 13th 06 05:11 AM
Referencing a filename in a formula ERR229 Excel Discussion (Misc queries) 2 May 12th 06 07:43 AM


All times are GMT +1. The time now is 05:00 AM.

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

About Us

"It's about Microsoft Excel"