Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

How do I show the sheet name / filename in a cell

Best of Excel

How do I show the sheet name / filename in a cell

by  xlbo  Posted    (Edited  )
This is very easy with code. It's actually pretty easy with formulae as well:

To display the full title of the Workbook in a cell - including the Sheet name:

=CELL("FILENAME",F10)

eg.[color green] H:\MSOffice\Macros\[Accessing document properties.xls]Sheet1[/color]

To display the Path Including Workbook Name:

=MID(CELL("FILENAME",F10), 1,FIND("]",CELL("FILENAME",F10)))

eg. [color green]H:\MSOffice\Macros\[TestFile.xls][/color]

To display the Path Excluding the Workbook Name:

=MID(CELL("FILENAME",F11), 1,FIND("[",CELL("FILENAME",F11))-1)

eg. [color green]H:\MSOffice\Macros\[/color]

To display the Filename:

=MID(CELL("FILENAME",F10),FIND("[",CELL("FILENAME",F10))+1,FIND("]",CELL("FILENAME",F10))-FIND("[",CELL("FILENAME",F10))-1)

eg. [color green]Accessing document properties.xls[/color]

To display the Sheet name:

=RIGHT(CELL("FILENAME",F10),LEN(CELL("FILENAME",F10))-FIND("]",CELL("FILENAME",F10)))

eg. [color green]Sheet1[/color]

Just enter the formula as above - very useful for referencing in code and linked formulae. The "F10" is just an arbitrary cell reference - it doesn't matter as long as it is consistent in the formula

[color red]Please note that these functions will not work until the workbook has been saved.[/color]

Credit for this must go to Julian Milano (Excel L list)
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top