Display the Sheet Name in a Cell - Excel Formula _ Computergaga
Display the Sheet Name in a Cell - Excel Formula _ Computergaga
Microsoft
Excel
Tips and
Tricks -
Computergaga
This blog post looks at using an Excel formula to display the sheet name in cell. By finding the sheet name using an Excel
formula, it ensures that if the sheet name is changed, the formula returns the new sheet tab name.
This tutorial covers two Excel formula examples. Firstly, using the CELL, MID and FIND functions. And then using the
TEXTAFTER function with CELL.
https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-name-in-a-cell/ 1/13
2/17/24, 5:05 PM Display the Sheet Name in a Cell - Excel Formula | Computergaga
It requires the information to return, entered as a string, and the reference to return the information from. A list is
provided of the different types of information CELL can return.
We need to use the function to return the filename from a given cell. Because our goal is to return the worksheet name,
it does not matter what cell we use. Any cell on the sheet will work. In this example, cell A1 has been used (choosing any
other cell would be weird, no?).
https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-name-in-a-cell/ 2/13
2/17/24, 5:05 PM Display the Sheet Name in a Cell - Excel Formula | Computergaga
=CELL("filename",A1)
This function above will return the full filename of the cell such as;
C:\Users\Computergaga\Desktop\[return-sheet-name.xlsx]Chicago
https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-name-in-a-cell/ 3/13
2/17/24, 5:05 PM Display the Sheet Name in a Cell - Excel Formula | Computergaga
(https://amzn.to/3Ns2NBC)
The FIND function is used to return the position of the closing “]” + 1. The “]” indicates the end of the workbook
reference, so the +1 returns the index for the first letter of the sheet name.
https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-name-in-a-cell/ 4/13
2/17/24, 5:05 PM Display the Sheet Name in a Cell - Excel Formula | Computergaga
Here is the full Excel formula to display the sheet name in a cell;
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,32)
The CELL function is used twice in this Excel formula. This is fine, but to reduce calculation, the LET function
(https://support.microsoft.com/en-au/office/let-function-34842dd8-b92b-4d3f-b325-b8b8f9908999) could have been
used to store the CELL formula result to be referenced later. This means it only calculates once, rather than twice.
=let(
filepath,CELL("filename",B2),
MID(filepath,FIND("]",filepath)+1,32)
)
https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-name-in-a-cell/ 5/13
2/17/24, 5:05 PM Display the Sheet Name in a Cell - Excel Formula | Computergaga
As its name suggests, the TEXTAFTER function returns all text after a given delimiter. It also has other cool features
beyond the scope of this requirement.
https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-name-in-a-cell/ 6/13
2/17/24, 5:05 PM Display the Sheet Name in a Cell - Excel Formula | Computergaga
In this formula the TEXTAFTER function uses the string returned by the CELL function and returns all text after the
closing square bracket “]” delimiter. This time, the reference is omitted from the CELL function. When a reference is
omitted, the cell that the formula belongs to is used.
=TEXTAFTER(CELL("filename"),"]")
Related Posts:
https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-name-in-a-cell/ 7/13
2/17/24, 5:06 PM Display the Sheet Name in a Cell - Excel Formula | Computergaga
N Function in Excel Moving Average in Excel Create a Picture Lookup in SEQUENCE Function in
(https://www.computergaga (https://www.computergaga Excel Excel
.com/blog/n-function-in- .com/blog/moving-average- (https://www.computergaga (https://www.computergaga
excel/) in-excel/) .com/blog/create-a-picture- .com/blog/sequence-
lookup-in-excel/) function-in-excel/)
Comments
Great function. I can get staff members to now remember where they put their files by this function.
Thanks
Reply
Tom says
6 August 2017 at 2:08 am (https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-name-in-
a-cell/#comment-946)
https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-name-in-a-cell/ 8/13
2/17/24, 5:06 PM Display the Sheet Name in a Cell - Excel Formula | Computergaga
Is there any way to reverse engineer this, so the sheet name is determined by a cell value?
Reply
This can only be done with a macro using a statement such as Activesheet.Name = Range(“A1”).Value
Reply
Sorry, but the filename (workbook name) is not the same as the sheet name inside a workbook.
“A worksheet is a collection of cells where you keep and manipulate the data. Each Excel workbook can
contain multiple worksheets.”
Reply
I know, Brian. The formula returns the filename and extracts the sheet name from it.
Reply
https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-name-in-a-cell/ 9/13
2/17/24, 5:06 PM Display the Sheet Name in a Cell - Excel Formula | Computergaga
Reply
Reply
Yes, there are differences between the two. Not in formulas but in other areas especially VBA and
Power Query.
Reply
Excel101 says
Hi! I’m just wondering what’s the meaning of the numbers +1 and 32?
https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-name-in-a-cell/ 10/13
2/17/24, 5:06 PM Display the Sheet Name in a Cell - Excel Formula | Computergaga
Reply
The + 1 is to start from the first character after the “]” and the 32 is a number to just ensure we
return enough characters. 32 is more character than we require. We do not know how many
characters in the sheet name, but we know 32 is more than enough.
Reply
https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-name-in-a-cell/ 11/13
2/17/24, 5:06 PM Display the Sheet Name in a Cell - Excel Formula | Computergaga
https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-name-in-a-cell/ 12/13
2/17/24, 5:06 PM Display the Sheet Name in a Cell - Excel Formula | Computergaga
PivotTables
(https://www.computerga
ga.com/blog/category/piv
ottables/)
Power BI
(https://www.computerga
ga.com/blog/category/po
wer-bi/)
Power Pivot
(https://www.computerga
ga.com/blog/category/po
wer-pivot/)
Power Query
(https://www.computerga
ga.com/blog/category/get-
transform-or-power-
query/)
VBA
(https://www.computerga
ga.com/blog/category/vba
/)
https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-name-in-a-cell/ 13/13