0% found this document useful (0 votes)
5 views

Display the Sheet Name in a Cell - Excel Formula _ Computergaga

This document provides a tutorial on how to display the sheet name in a cell using Excel formulas. It explains the use of the CELL, MID, FIND, and TEXTAFTER functions to extract the sheet name from the full filename. The tutorial includes examples and variations of the formulas for different Excel versions.

Uploaded by

AMANUALE D
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Display the Sheet Name in a Cell - Excel Formula _ Computergaga

This document provides a tutorial on how to display the sheet name in a cell using Excel formulas. It explains the use of the CELL, MID, FIND, and TEXTAFTER functions to extract the sheet name from the full filename. The tutorial includes examples and variations of the formulas for different Excel versions.

Uploaded by

AMANUALE D
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

2/17/24, 5:05 PM Display the Sheet Name in a Cell - Excel Formula | Computergaga

Microsoft
Excel
Tips and
Tricks -
Computergaga

Excel Formula to Display the Sheet Name in


Cell

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.

Let’s begin by looking at the CELL function.

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

CELL Function in Excel


The CELL function (https://www.computergaga.com/blog/unleash-the-power-of-excels-cell-function/)is a fantastic, and
relatively unknown, function in Excel (https://www.computergaga.com/excel/functions/). Its purpose is to return
information about a cell such as its column, cell colour, its protected state, or filename.

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)

Returning Just the Sheet Name to a Cell


Now that we have the filename, we need to extract just the sheet name. The MID and FIND functions
(https://www.computergaga.com/blog/use-the-mid-and-find-functions-to-extract-text/)will be used for this.

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.

The MID function (https://www.computergaga.com/excel/functions/mid-function/) then extracts up to the next 32


characters. This is an excessive number but because sheet names cannot have more than 31 characters it ensures the
full name is returned whatever it may be.

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)

Watch the Video


Return Sheet Name into a Cell - Excel Formula

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

Using the TEXTAFTER Function


In Excel 365, there are two new functions named TEXTBEFORE and TEXTAFTER
(https://www.computergaga.com/excel/functions/excel-textbefore-and-textafter-functions/). The TEXTAFTER function
makes the process of returning a sheet name to cell even easier.

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"),"]")

Excel TEXTBEFORE and TEXTAFTER Functions (SE…


(SE…

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

Neil Watkins says


19 July 2016 at 10:29 pm (https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-name-in-
a-cell/#comment-945)

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

computergaga (https://www.computergaga.com) says


6 August 2017 at 7:27 pm (https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-
name-in-a-cell/#comment-947)

This can only be done with a macro using a statement such as Activesheet.Name = Range(“A1”).Value

Reply

Brian S Blackwell says


26 January 2021 at 4:34 pm (https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-name-
in-a-cell/#comment-5308)

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

Alan Murray says


26 January 2021 at 4:42 pm (https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-
name-in-a-cell/#comment-5309)

I know, Brian. The formula returns the filename and extracts the sheet name from it.

Reply

Love Rai says


20 July 2021 at 1:49 pm (https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-name-in-a-
cell/#comment-11773)

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

Note :- Formula Work only if your Sheet Name in Numeric


=”=’E:\Contacts\”&”[“&SUM(MID(CELL(“filename”,A1),FIND(“]”,CELL(“filename”,A1))+1,256))-1&”.csv”&”]”&SU
M(MID(CELL(“filename”,A1),FIND(“]”,CELL(“filename”,A1))+1,256))-1&”‘!$B$1048576″
Use this Formula To Get Value from other Excel Sheet
________________

Define Path = “=’E:\Contacts\”&”[”


Give Sheet Name [if Sheet Name in Numericl] =
SUM(MID(CELL(“filename”,A1),FIND(“]”,CELL(“filename”,A1))+1,256))-1&”.csv”&”]”&SUM(MID(CELL(“filename”,
A1),FIND(“]”,CELL(“filename”,A1))+1,256))-1
Cell No. = !$B$1048576

Reply

Johan Jordaan says


24 July 2021 at 10:12 pm (https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-name-in-
a-cell/#comment-11899)

Is there a difference between Excel in Windows and Excel on Macbook?

Reply

Alan Murray says


26 July 2021 at 8:12 pm (https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-name-
in-a-cell/#comment-11955)

Yes, there are differences between the two. Not in formulas but in other areas especially VBA and
Power Query.

Reply

Excel101 says

24 September 2021 at 7:27 pm (https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-


name-in-a-cell/#comment-14909)

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

Alan Murray says


10 November 2021 at 4:55 pm (https://www.computergaga.com/blog/excel-formula-to-display-the-
sheet-name-in-a-cell/#comment-18027)

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

Contact Useful Links Course Topics Join Our Mailing


List
[email protected] Home Charts
m (https://www.computerga (https://www.computerga "40 Incredible Excel
(mailto:admin@computer ga.com/) ga.com/blog/category/cha Tricks" ebook
gaga.com) Excel Online Courses rts/) FREE when you sign
(https://www.computerga Courses up for the latest tips
ga.com/online-courses/) (https://www.computerga Name:
Tutorials ga.com/blog/category/cou
Email:
(https://www.computerga rses/)
ga.com/tutorials/) Dashboards
Sitemap (/sitemap.xml) (https://www.computerga
Privacy Policy ga.com/blog/category/das
(https://www.computerga hboards/)
ga.com/privacy-policy/) Downloads
(https://uk.linkedin.com/in
Jobs by Jooble (https://www.computerga
/alanmurray-
(https://jooble.org/) ga.com/blog/category/do
computergaga)
wnloads/)
Excel Tips
(https://www.computerga
ga.com/blog/category/exc
el-tips/)
Formulas
(https://www.computerga
(https://twitter.com/Comp
ga.com/blog/category/for
utergaga1)
mulas/)
Mail Merge
(https://www.computerga
ga.com/blog/category/mai
l-merge/)
Office
(https://www.youtube.co (https://www.computerga
m/user/Computergaga? ga.com/blog/category/offi
sub_confirmation=1) ce/)

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
/)

© Copyright 2009 Computergaga (https://www.computergaga.com/) · All Rights Reserved ·

https://www.computergaga.com/blog/excel-formula-to-display-the-sheet-name-in-a-cell/ 13/13

You might also like