XL: Macroless Method to Display the File Name of a WorksheetID: Q99348
|
In Microsoft Excel, if you want to create a formula that displays the
file name of a worksheet in a cell but you do not want to use a macro,
use the appropriate following method.
For example, to return the file name of a file with the path
C:\EXCEL\DATA\TEST.XLS (if you are using Microsoft Excel for Windows) or
HD:Microsoft Excel:Data Files:Test (if you are using Microsoft Excel for
the Macintosh), the following formulas return TEST.XLS or Test.
If you are using Microsoft Excel 5.0 or later, the formulas in this
article
=RIGHT(CELL("filename"),LEN(CELL("filename"))-
MAX(IF(NOT(ISERR(SEARCH("\",CELL("filename"),
ROW(1:255)))),SEARCH("\",CELL("filename"),ROW(1:255)))))
=MID(CELL("filename"),SEARCH("[",CELL("filename"))+1,SEARCH("]",CELL
("filename"))-SEARCH("[",CELL("filename"))-1)
=RIGHT(CELL("filename"),LEN(CELL("filename"))-
MAX(IF(NOT(ISERR(SEARCH(":",CELL("filename"),
ROW(1:255)))),SEARCH(":",CELL("filename"),ROW(1:255)))))
=MID(CELL("filename"),SEARCH("[",CELL("filename"))+1,SEARCH("]",CELL
("filename"))-SEARCH("[",CELL("filename"))-1)
"Function Reference," version 4.0, Pages 46, 239, 252, 377
"Function Reference," version 3.0, Pages 26, 137, 200, 208
Additional query words: XL98 XL97 XL7 XL5 XL4 XL3 macrosheet template howto
Keywords : xlformula
Version : WINDOWS:3.0,4.0,4.0a,5.0,5.0c,7.0,97; MACINTOSH:3.0,4.0,4.0a,5.0,98
Platform : MACINTOSH OS/2 WINDOWS
Issue type : kbinfo
Last Reviewed: April 6, 1999