Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

filename in spreadsheet 3

Status
Not open for further replies.

jnims

Electrical
Sep 11, 2000
75
Is there an easy way to show a spreadsheet's filename and path without typing it in manually?

 
Replies continue below

Recommended for you

Type in the cell where you want the filame:

=CELL("filename")

that should do

regards
Mogens
 
Thanks Mogen, works like a charm.

 
I would advise you to use CELL("filename",A1) (or any other address of a cell on the sheet). That way you are sure that the filename+sheet tab name is always the name of the worksheet that the function is on (or more specifically, where the referenced cell is on).
Just using CELL("filename") can give funny results when working on multiple workbooks/sheets. Regards,

Joerd
 
Thats a good one joerd

I have experienced that, bud didn't know this option.

regards
Mogens
 
Any way to just display the filename and not the path ?
 
Yes, you have probably noticed that the CELL function gives you a long string, with the filename between square brackets.
So you "only" have to parse the string, find the square brackets, and return the part of the string between the brackets as the filename. :)
All in one, this gives you something like:

=MID(CELL("filename",A1),SEARCH("[",CELL("filename",A1))+1,SEARCH("]",CELL("filename",A1))-SEARCH("[",CELL("filename",A1))-1)

Have fun. Regards,

Joerd
 
By the way, same can be done more nicely in VBA, by a user defined function:

Code:
Function Filename(r As Range)
    Application.Volatile
    Filename = r.Worksheet.Parent.Name
End Function

Call this function from your sheet as =Filename(A1), for example. Regards,

Joerd
 
Thanks [thumbsup2]
I had tried other ways but I was being too simplistic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor