Is it possible to get the sheetname?

How can I get the sheet name in a cell? (I have more than one sheet, I want to get the current on each sheet)


Solution 1:

Microsoft explains you might need to use an array formula to get the sheet name:

To display the name of the current worksheet, type the following formula as an array formula

=RIGHT(CELL("filename"),LEN(CELL("filename"))-
  MAX(IF(NOT(ISERR(SEARCH("\",CELL("filename"),
  ROW(1:255)))),SEARCH("\",CELL("filename"),ROW(1:255)))))

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 CTRL+SHIFT+ENTER.

Also note that this is very platform dependent. On a Mac, you'll need different formulas, as it uses different path separators. Also, it might work differently in OpenOffice.org and other alternatives. And when using on an unsaved workbook, you might get #VALUE! instead.

When not using an array formula, you might get the name of the workbook (the last part of its file name), like so:

To return the name of the workbook only, like used in the following formula:

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

Solution 2:

Here's a formula.

=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,256)

(Link to more info)

Solution 3:

First save your file than enter this formula anywhere

=RIGHT(CELL("filename"),LEN(CELL("filename"))-FIND("]",CELL("filename")))