This site will look better if you upgrade to a browser that supports web standards.
Want to put the name of your sheet in a cell, and make it dynamic so that it changes when the sheet name changes? How about the name of your workbook? XL's CELL() function can do that for you.
CELL("filename", range_ref) returns the entire path and worksheet name of the active sheet. A couple of notes
Here are some options for returning portions of the filename and path. Assume that these formulae are placed in Cell A1 of Sheet2 of Workbook Workbook1.xls, which is saved in the (Macintosh) Panther:Users:je:Documents:XL files folder.
=CELL("filename",A1)
returns (again, Mac path separators):
Panther:Users:je:Documents:XL Files:[Workbook1.xls]Sheet2
=LEFT(CELL("filename",A1), FIND("]",CELL("filename", A1)))
returns
Panther:Users:je:Documents:XL Files:[Workbook1.xls]
=LEFT(CELL("filename",A1),FIND("[",CELL("filename",A1)) - 2)
returns
Panther:Users:je:Documents:XL Files
=MID(LEFT(CELL("filename",A1), FIND("]", CELL("filename", A1))- 1), FIND("[",CELL("filename", A1))+1, 255)
returns (note: there's nothing special about 255 - it's just a large number to make sure we get all of the filename):
Workbook1.xls
=MID(CELL("filename",A1), FIND("]", CELL("filename", A1))+ 1, 255)
returns
Sheet2
This page last updated
© Copyright 2001 - 2004 McGimpsey and Associates. Except where noted, all code on this site may be distributed under the Gnu GPL. Acknowledgement is appreciated.
Not familiar with macros? See David McRitchie's Getting Started With Macros
About Event Macros>