How to display the file name of a worksheet without using a macro in Excel for Mac (323225)



The information in this article applies to:

  • Microsoft Excel 2004 for Mac
  • Microsoft Excel X for Mac
  • Microsoft Excel 2001 for Mac
  • Microsoft Excel 98 Macintosh Edition

This article was previously published under Q323225
For a Microsoft Excel for Windows version of this article, see 214084.

SUMMARY

This article describes how to create a formula that displays the file name of a worksheet in a cell.

For example, for a file with the path HD:Users:local:Desktop, the formula returns

HD:Users:local:Desktop:(filename)Sheet1

where HD is the name of your hard disk and filename is the name of your saved Excel workbook.

MORE INFORMATION

To display the full path and worksheet name of the current workbook, type the following formula as an array formula

=Cell("filename")

where "filename" is literally the word "filename", in quotation marks.

NOTE: You must input this formula as an array formula. To input a formula as an array formula, press COMMAND+RETURN.

The formula returns the full path and worksheet name of the current workbook as long as the workbook has been saved at least once. If you use this formula in an unsaved workbook, the formula cell remains blank until you save the workbook.

To return the name of the workbook only, use the following formula:

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

NOTE: You do not have to input this formula as an array formula.

If you use this formula in an unsaved workbook, you receive the following error:
#VALUE!
When you save the workbook, the file name replaces the error.

Modification Type:MajorLast Reviewed:2/9/2005
Keywords:kbinfo KB323225