Содержание
- Get Sheet Name
- Select worksheets
- Need more help?
- Get sheet name only
- Related functions
- Summary
- Generic formula
- Explanation
- Workbook path
- TEXTAFTER function
- MID + FIND function
- How to Get the Sheet Name in Excel? Easy Formula
- Get Sheet Name Using the CELL Function
- Alternative Formula to Get Sheet Name (MID formula)
- Fetching Sheet Name and Adding Text to it
- How to Find Specific Sheet Name in Excel
- 4 Answers 4
- Related
- Hot Network Questions
- Subscribe to RSS
Get Sheet Name
To return the sheet name in a cell, use CELL, FIND and MID in Excel. There’s no built-in function in Excel that can get the sheet name.
1. The CELL function below returns the complete path, workbook name and current worksheet name.
Note: instead of using A1, you can refer to any cell on the first worksheet to get the name of this worksheet.
2. Use the FIND function to find the position of the right bracket. Add 1 to return the start position of the sheet name.
3. To extract a substring, starting in the middle of a string, use the MID function. First argument (formula from step 1). Second argument (formula from step 2). Third argument (31).
Explanation: the MID function shown above starts at position 24 and extracts 31 characters (maximum length of a worksheet name).
4. You may want to add text to the name of the sheet. Simply use the ampersand (&) operator as shown below.
5. To get the name of the second worksheet, simply refer to any cell on the second worksheet.
Pro tip: use Excel VBA to display the sheet names of all Excel files in a directory. You can find detailed instructions here.
Источник
Select worksheets
By clicking the sheet tabs at the bottom of the Excel window, you can quickly select one or more sheets. To enter or edit data on several worksheets at the same time, you can group worksheets by selecting multiple sheets. You can also format or print a selection of sheets at the same time.
Click the tab for the sheet you want to edit. The active sheet will be a different color than other sheets. In this case, Sheet4 has been selected.
If you don’t see the tab that you want, click the scrolling buttons to locate the tab. You can add a sheet by pressing the Add Sheet button to the right of the sheet tabs.
Two or more adjacent sheets
Click the tab for the first sheet, then hold down SHIFT while you click the tab for the last sheet that you want to select.
By keyboard: First, press F6 to activate the sheet tabs. Next, use the left or right arrow keys to select the sheet you want, then you can use Ctrl+Space to select that sheet. Repeat the arrow and Ctrl+Space steps to select additional sheets.
Two or more nonadjacent sheets
Click the tab for the first sheet, then hold down CTRL while you click the tabs of the other sheets that you want to select.
By keyboard: First, press F6 to activate the sheet tabs. Next, use the left or right arrow keys to select the sheet you want, then you can use Ctrl+Space to select that sheet. Repeat the arrow and Ctrl+Space steps to select additional sheets.
All sheets in a workbook
Right-click a sheet tab, and then click the Select All Sheets option.
TIP: After choosing multiple sheets, [Group] appears in the title bar at the top of the worksheet. To cancel a selection of multiple worksheets in a workbook, click any unselected worksheet. If no unselected sheet is visible, right-click the tab of a selected sheet, and then click Ungroup Sheets on the shortcut menu.
Data that you enter or edit in the active worksheet will appear in all selected sheets. These changes might replace data on the active sheet and—perhaps unintentionally—on other selected sheets.
Data that you copy or cut in grouped sheets cannot be pasted onto another sheet, because the size of the copy area includes all layers of the selected sheets (which is different from the paste area in a single sheet). It’s important to ensure that only one sheet is selected before you copy or move data to another worksheet.
When you save a workbook that contains grouped sheets and then close the workbook, the sheets that you selected remain grouped when you reopen that workbook.
In Excel for the web you can’t select more than one sheet at a time, but it’s easy to find the sheet you want.
Select the All Sheets menu, then choose a sheet from the menu to open it.
From the sheets listed along the bottom, select a sheet name to open it. Use the arrows just beside the All Sheets menu to scroll forward and backward through sheets to review ones that aren’t currently visible.
Need more help?
You can always ask an expert in the Excel Tech Community or get support in the Answers community.
Источник
Get sheet name only
Summary
To get the name of the current worksheet (i.e. current tab) you can use a formula based on the CELL function together with the TEXTAFTER function. In the example shown, the formula in E5 is:
The result is «September» the name of the current worksheet in the workbook shown. In older versions of Excel which do not provide the TEXTAFTER function, you can use an alternate formula based on the MID and FIND function. Both approaches are explained below.
Generic formula
Explanation
In this example, the goal is to return the name of the current worksheet (i.e. tab) in the current workbook with a formula. This is a simple problem in the latest version of Excel, which provides the TEXTAFTER function. In older versions of Excel, you can use an alternative formula based on the MID and FIND functions. Both formula options rely on the CELL function to get a full path to the current workbook. Read below for a full explanation.
Workbook path
The first step in this problem is to get the workbook path, which includes the workbook and worksheet name. This can be done with the CELL function like this:
With the info_type argument set to «filename», and reference set to cell A1 in the current worksheet, the result from CELL is a full path as a text string like this:
Notice the sheet name begins after the closing square bracket («]»). The problem now becomes how to extract the sheet name from the path? The best way to do this depends on your Excel version. Use the TEXTAFTER function if available. Otherwise, use the MID and FIND functions as explained below.
TEXTAFTER function
In Excel 365, the easiest option is to use the TEXTAFTER function with the CELL function like this:
The CELL function returns the full path to the current workbook as explained above, and this text string is delivered to TEXTAFTER as the text argument. Delimiter is set to «]» in order to retrieve only text that occurs after the closing square bracket («]»). In the example shown, the final result is «September» the name of the current worksheet in the workbook shown.
MID + FIND function
In older versions of Excel that do not offer the TEXTAFTER function, you can use the MID function with the FIND function to extract the sheet name:
The core of this formula is the MID function, which is used to extract text starting at a specific position in a text string. Working from the inside out, the first CELL function returns the full path to the current workbook to the MID function as the text argument:
We then need to tell MID where to start extracting text. To do this, we use the FIND function with a second call to the CELL function to locate the «]» character. We want MID to start extracting text after the «]» character, so we use the FIND function to get the position, then add 1:
The result from the above snippet is returned to the MID function as start_num. For the num_chars argument, we hard-code the number 255*. The MID function doesn’t care if the number of characters requested is larger than the length of the remaining text, it simply extracts all remaining text. The final result is «September» the name of the current worksheet in the workbook shown.
*Note: In Excel user interface, you can’t name a worksheet longer than 31 characters, but the file format itself permits worksheet names up to 255 characters, so this ensures the entire name is retrieved.
Источник
How to Get the Sheet Name in Excel? Easy Formula
When working with Excel spreadsheets, sometimes you may have a need to get the name of the worksheet.
While you can always manually enter the sheet name, it won’t update in case the sheet name is changed.
So if you want to get the sheet name, so that it automatically updates when the name is changed, you can use a simple formula in Excel.
In this tutorial, I will show you how to get the sheet name in Excel using a simple formula.
This Tutorial Covers:
Get Sheet Name Using the CELL Function
CELL function in Excel allows you to quickly get information about the cell in which the function is used.
This function also allows us to get the entire file name as a result of the formula.
Suppose I have an Excel workbook with the sheet name ‘Sales Data’
Below is the formula that I have used in any cells in the ‘Sales Data’ worksheet:
As you can see, it gave me the whole address of the file in which I am using this formula.
But I needed only the sheet name, not the whole file address,
Well, to get the sheet name only, we will have to use this formula along with some other text formulas, so that it can extract only the sheet name.
Below is the formula that will give you only the sheet name when you use it in any cell in that sheet:
The above formula will give us the sheet name in all scenarios. And the best part is that it would automatically update in case you change the sheet name or the file name.
Note that the CELL formula only works if you have saved the workbook. If you haven’t, then it would return a blank (as it has no idea what the workbook path is)
Wondering how this formula works? Let me explain!
The CELL formula gives us the whole workbook address along with the sheet name at the end.
One rule it would always follow is to have the sheet name after the square bracket (]).
Knowing this, we can find out the position of the square bracket, and then extract everything after it (which would be the sheet name)
And that’s exactly what this formula does.
The FIND part of the formula looks for ‘]’ and return it’s position (which is a number that denotes the number of characters after which the square bracket is found)
We use this position of the square bracket within the RIGHT formula to extract everything after that square bracket
One major issue with the CELL formula is that it’s dynamic. So if you use it in Sheet1 and then go to Sheet2, the formula in Sheet1 would update and show you the name as Sheet2 (despite the formula being on Sheet1). This happens as the CELL formula considers the cell in the active sheet and gives the name for that sheet, no matter where it is in the workbook. A workaround would be to hit the F9 key when you want to update the CELL formula in the active sheet. This will force a recalculation.
Alternative Formula to Get Sheet Name (MID formula)
There are many different ways to do the same thing in Excel. And in this case, there is another formula that works just as well.
Instead of the RIGHT function, it uses the MID function.
Below is the formula:
This formula works similarly to the RIGHT formula, where it first finds the position of the square bracket (using the FIND function).
It then uses the MID function to extract everything after the square bracket.
Fetching Sheet Name and Adding Text to it
If you’re building a dashboard, you may want to not just get the name of the worksheet, but also append a text before or after it.
For example, if you have a sheet name 2021, you may want to get the result as ‘Summary of 2021’ (and not just the sheet name).
This can easily be done by combining the formula we saw above with the text we want before it using the ampersand operator.
Below is the formula that will add the text ‘Summary of ‘ before the sheet name:
The ampersand operator (&) simply combines the text before the formula with the result of the formula. You can also use the CONCAT or CONCATENATE function instead of an ampersand.
Similarly, if you want to add any text after the formula, you can use the same ampersand logic (i.e., have the ampersand after the formula followed by the text that you want to append).
So these are two simple formulas that you can use to get the sheet name in Excel.
I hope you found this tutorial useful.
Other Excel tutorials you may also like:
Источник
How to Find Specific Sheet Name in Excel
I have a excel file with 55 sheets in it
It is very tedious to find a specific sheet name in the excel file since it has 55 sheets in it
I have used the search function to find specific sheet name but it is not searching the sheet name
Is there a way to search a Sheet name in Excel
4 Answers 4
In 2013. RIGHT CLICK on the Navigation area in the STATUS BAR (far left area with buttons) and the sheet names will appear and you can choose whichever you want to activate. Joan B
The build in search function in Excel does not allow you to search in the names of the sheets. You could instead include the code bellow as a macro in either the actual workbook or as a Add-In to your Excel installation.
When this code is called it will prompt you for a search name and try to find and select the sheet with that name.
You can use VBA to create a list of all of the worksheets in your workbook automatically.
If you insert this code into the VB panel for your workbook, then go back to your workbook and make a blank sheet and run this as a macro:
This should then create a full list of all of your worksheets. You could also then assign a hyperlink to each one to jump to that sheet easily if you wanted.
Quickest to run a simple test as below
Hot Network Questions
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.3.17.43323
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Источник
I have a excel file with 55 sheets in it
It is very tedious to find a specific sheet name in the excel file since it has 55 sheets in it
I have used the search function to find specific sheet name but it is not searching the sheet name
Is there a way to search a Sheet name in Excel
asked Apr 16, 2014 at 7:08
In 2013… RIGHT CLICK on the Navigation area in the STATUS BAR (far left area with buttons) and the sheet names will appear and you can choose whichever you want to activate. Joan B
answered Oct 9, 2014 at 3:19
The build in search function in Excel does not allow you to search in the names of the sheets. You could instead include the code bellow as a macro in either the actual workbook or as a Add-In to your Excel installation.
When this code is called it will prompt you for a search name and try to find and select the sheet with that name.
Sub SearchSheetName()
Dim sName As String
Dim sFound As Boolean
sName = InputBox(prompt:="Enter sheet name to find in workbook:", Title:="Sheet search")
If sName = "" Then Exit Sub
sFound = False
On Error Resume Next
ActiveWorkbook.Sheets(sName).Select
If Err = 0 Then sFound = True
On Error GoTo 0
If sFound = False Then
MsgBox prompt:="The sheet '" & sName & "' could not be found in this workbook!", Buttons:=vbExclamation, Title:="Search result"
End If
End Sub
answered Apr 16, 2014 at 8:17
NetlohNetloh
2542 silver badges7 bronze badges
2
You can use VBA to create a list of all of the worksheets in your workbook automatically.
If you insert this code into the VB panel for your workbook, then go back to your workbook and make a blank sheet and run this as a macro:
Sub SheetNames()
Columns(1).Insert
For i = 1 To Sheets.Count
Cells(i, 1) = Sheets(i).Name
Next i
End Sub
This should then create a full list of all of your worksheets. You could also then assign a hyperlink to each one to jump to that sheet easily if you wanted.
answered Apr 16, 2014 at 7:59
Quickest to run a simple test as below
Sub Tested()
Dim strTest As String
strTest = "Your Sheet Name"
MsgBox strTest & "exists:= " & SheetExists(strTest)
End Sub
Function SheetExists(ByVal strTest As String) As Boolean
Dim ws As Worksheet
On Error Resume Next
Set ws = ActiveWorkbook.Sheets(strTest)
SheetExists = (Not ws Is Nothing)
End Function
answered Apr 16, 2014 at 11:16
brettdjbrettdj
2,09720 silver badges23 bronze badges
See all How-To Articles
This tutorial demonstrates how to search all sheets to find a word or phrase in Excel and Google Sheets.
Search All Sheets
The search functionality in Excel searches in the current worksheet by default. However, you can also make it search all sheets in the file. Say you have the following Excel file with three sheets (January-2021, February-2021, and March-2021) and the same columns: Product Name and Price.
You want to search for Keyboard in the entire workbook. (It appears in cell B2 in sheet January-2021 and B7 in sheet March-2021.)
- First, select all sheets. Press and hold CTRL and click on sheet names (January-2021, February-2021, and March-2021.)
All sheets in the file are selected.
- In the Ribbon, go to Home > Find & Select > Find (or use the shortcut CTRL + F).
- Now, in the Find what box enter the word you want to find (“Keyboard“) and click Find All.
The bottom section of the window displays all appearances of the searched term in the workbook. As you can see, there are matches in the January-2021 (cell B2) and March-2021 (B7) sheets. If you click Find Next, you are cycled through each found cell.
See also: Using Find and Replace in Excel VBA
Search All Google Sheets
By default, Google Sheets searches all sheets for a term when you use Find and Replace.
- In the Menu, go to Edit > Find and replace (or use the shortcut CTRL + H).
- In the Find box enter the word you want to find (“Keyboard“) and click Find.
As a result, cell B2 in the January-2021 sheet is selected.
- Now when you click Find again, you go to the next instance of Keyboard (B7 in March-2021, and so on) through the last appearance of the term.
Unlike Excel, Google Sheets doesn’t offer the option to display a list of instances.
In this example, the goal is to return the name of the current worksheet (i.e. tab) in the current workbook with a formula. This is a simple problem in the latest version of Excel, which provides the TEXTAFTER function. In older versions of Excel, you can use an alternative formula based on the MID and FIND functions. Both formula options rely on the CELL function to get a full path to the current workbook. Read below for a full explanation.
Workbook path
The first step in this problem is to get the workbook path, which includes the workbook and worksheet name. This can be done with the CELL function like this:
CELL("filename",A1)
With the info_type argument set to «filename», and reference set to cell A1 in the current worksheet, the result from CELL is a full path as a text string like this:
"C:pathtofolder[workbook.xlsx]sheetname"
Notice the sheet name begins after the closing square bracket («]»). The problem now becomes how to extract the sheet name from the path? The best way to do this depends on your Excel version. Use the TEXTAFTER function if available. Otherwise, use the MID and FIND functions as explained below.
TEXTAFTER function
In Excel 365, the easiest option is to use the TEXTAFTER function with the CELL function like this:
=TEXTAFTER(CELL("filename",A1),"]")
The CELL function returns the full path to the current workbook as explained above, and this text string is delivered to TEXTAFTER as the text argument. Delimiter is set to «]» in order to retrieve only text that occurs after the closing square bracket («]»). In the example shown, the final result is «September» the name of the current worksheet in the workbook shown.
MID + FIND function
In older versions of Excel that do not offer the TEXTAFTER function, you can use the MID function with the FIND function to extract the sheet name:
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255)
The core of this formula is the MID function, which is used to extract text starting at a specific position in a text string. Working from the inside out, the first CELL function returns the full path to the current workbook to the MID function as the text argument:
CELL("filename",A1) // get full path
We then need to tell MID where to start extracting text. To do this, we use the FIND function with a second call to the CELL function to locate the «]» character. We want MID to start extracting text after the «]» character, so we use the FIND function to get the position, then add 1:
FIND("]",CELL("filename",A1))+1 // get start number
The result from the above snippet is returned to the MID function as start_num. For the num_chars argument, we hard-code the number 255*. The MID function doesn’t care if the number of characters requested is larger than the length of the remaining text, it simply extracts all remaining text. The final result is «September» the name of the current worksheet in the workbook shown.
*Note: In Excel user interface, you can’t name a worksheet longer than 31 characters, but the file format itself permits worksheet names up to 255 characters, so this ensures the entire name is retrieved.
I’m not opposed to using VBA. I think it’s great fun and it can be very useful. But in a business setting, if VBA need not be used, it needs not to be used.
Recently, for example, someone asked an Excel forum how to write a VBA macro that would list all the sheets in a workbook. This macro is needed, the Excel user said, because he has a lot of sheets in his workbook and he wants a quick way to find a specific sheet.
There’s an easier way to solve this problem.
Just right-click on the little arrows in the bottom-left corner of your workbook. You’ll see a list of up to 15 worksheets in your workbook. If your workbook contains more that 15 sheets, click on More Sheets at the bottom of the list. This brings up a dialog that lists all sheets in your workbook.
To activate any of the sheets in the list of 15, just click on the name. In the dialog, just double-click on the name, or select the name and then choose OK.
I have searched the excel function documentation and general MSDN search but have been unable to find a way to return the sheet name without VBA.
Is there a way to get the sheet name in an excel formula without needing to resort to VBA?
pnuts
58k11 gold badges85 silver badges137 bronze badges
asked Feb 1, 2015 at 17:27
Not very good with excel, but I found these here
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,256)
and A1
can be any non-error cell in the sheet.
For the full path and name of the sheet, use
=CELL("filename",A1)
answered Feb 1, 2015 at 17:31
TravisTravis
1,2641 gold badge16 silver badges33 bronze badges
4
Here’s a reasonably short one that has a couple added benefits:
-
Does a reverse lookup (most other answers go wrong direction) by using the often ignored
REPT
function. -
A1
seems like a poor choice as there’s a considerably higher chance iterrors
compared to…$FZZ$999999
. -
Don’t forget to absolute. Copying and pasting some of the other examples could error due to referential changes.
-
The
?
is intentional as that shouldn’t be in the file path.=SUBSTITUTE(RIGHT(SUBSTITUTE(CELL("Filename",$FZZ$999999), "]",REPT("?", 999)), 999),"?","")
answered Jun 20, 2019 at 0:38
pgSystemTesterpgSystemTester
8,7802 gold badges22 silver badges49 bronze badges
The below will isolate the sheet name:
=RIGHT(CELL("filename"),LEN(CELL("filename"))-FIND("]",CELL("filename")))
eli-k
10.7k11 gold badges43 silver badges44 bronze badges
answered Aug 8, 2016 at 3:52
2
For recent versions of Excel, the formula syntax is:
=MID(CELL("filename";A1);FIND("]";CELL("filename";A1))+1;255)
Wizhi
6,3684 gold badges24 silver badges47 bronze badges
answered Oct 17, 2018 at 10:59
OrbitOrbit
2121 silver badge7 bronze badges
None of the formulas given in other answers supports the case if there is character ] in filepath.
The formula below is more complex, but it can handle such cases properly:
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1),FIND("?",SUBSTITUTE(CELL("filename",A1),"","?",LEN(CELL("filename",A1))-LEN(SUBSTITUTE(CELL("filename",A1),"","")))))+1,LEN(CELL("filename",A1)))
answered Apr 19, 2019 at 1:47
mielkmielk
3,88012 silver badges19 bronze badges
0
I had a module already open so I made a custom function:
Public Function Sheetname (ByRef acell as Range) as string
Sheetname = acell.Parent.Name
End Function
eli-k
10.7k11 gold badges43 silver badges44 bronze badges
answered Dec 21, 2017 at 15:00
3
Had a square bracket ‘]’ in the file name, so needed to modify the above formula as per the following to find the last occurrence of the square bracket.
Verified that this works for 0,1 or more square brackets in the file name / path.
=RIGHT(CELL("filename"),LEN(CELL("filename")) - FIND("]]]",SUBSTITUTE(CELL("filename"),"]","]]]",LEN(CELL("filename"))-LEN(SUBSTITUTE(CELL("filename"),"]","")))))
- Replaces all square brackets using the substitute function, then compares the length of the result with the length of the file name to identify the number of square brackets in the file name.
- Uses the number of occurrences of square brackets to substitute the last square bracket with 3 sequential square brackets ‘]]]’
- Uses the Find function to identify the location of the 3 square brackets in the string
- Subtracts the location of the 3 square brackets from the length of the full path
- Uses the result to get the right most characters (being the sheet name)
Previous comment above about saving the workbook first is also a key, as you’ll otherwise receive the #Value! result.
answered Jun 14, 2019 at 2:27
JokeyJokey
313 bronze badges
The below works for me and is simpler (to me at least) than other solutions, while still handling a square bracket in the file name:
=MID(CELL("filename", A1),6+SEARCH(".xlsx]",CELL("filename", A1)),32)
This assumes it is an «xlsx» file and that the filename will not contain «.xlsx]» in addition to the xlsx suffix, which in my case is an assumption that is safe enough to make.
If you wanted to handle both «.xlsx» and «.xls» file names, you could use:
=MID(SUBSTITUTE(CELL("filename", A1),".xls]",".xlsx]"),6+SEARCH(".xlsx]",SUBSTITUTE(CELL("filename", A1),".xls]",".xlsx]")),32)
answered Dec 26, 2020 at 21:19
mwagmwag
3,36929 silver badges36 bronze badges
I’m pretty sure you could have Googled this. I just did, and here is the very first thing that came up for me.
In Excel it is possible to use the CELL function/formula and the MID and FIND to return the name of an Excel Worksheet in a Workbook. The formula below shows us how;
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,256)
Where A1 is any non error cell on the Worksheet. If you want the full path of the Excel Workbook, simply use;
=CELL("filename",A1)
The only catch is that you have to save the file for this to work!
answered Feb 8, 2017 at 21:42
ASHASH
20.2k18 gold badges80 silver badges183 bronze badges
0
To return the sheet name in a cell, use CELL, FIND and MID in Excel. There’s no built-in function in Excel that can get the sheet name.
1. The CELL function below returns the complete path, workbook name and current worksheet name.
Note: instead of using A1, you can refer to any cell on the first worksheet to get the name of this worksheet.
2. Use the FIND function to find the position of the right bracket. Add 1 to return the start position of the sheet name.
3. To extract a substring, starting in the middle of a string, use the MID function. First argument (formula from step 1). Second argument (formula from step 2). Third argument (31).
Explanation: the MID function shown above starts at position 24 and extracts 31 characters (maximum length of a worksheet name).
4. You may want to add text to the name of the sheet. Simply use the ampersand (&) operator as shown below.
5. To get the name of the second worksheet, simply refer to any cell on the second worksheet.
Pro tip: use Excel VBA to display the sheet names of all Excel files in a directory. You can find detailed instructions here.
When working with Excel spreadsheets, sometimes you may have a need to get the name of the worksheet.
While you can always manually enter the sheet name, it won’t update in case the sheet name is changed.
So if you want to get the sheet name, so that it automatically updates when the name is changed, you can use a simple formula in Excel.
In this tutorial, I will show you how to get the sheet name in Excel using a simple formula.
Get Sheet Name Using the CELL Function
CELL function in Excel allows you to quickly get information about the cell in which the function is used.
This function also allows us to get the entire file name as a result of the formula.
Suppose I have an Excel workbook with the sheet name ‘Sales Data’
Below is the formula that I have used in any cells in the ‘Sales Data’ worksheet:
=CELL("filename"))
As you can see, it gave me the whole address of the file in which I am using this formula.
But I needed only the sheet name, not the whole file address,
Well, to get the sheet name only, we will have to use this formula along with some other text formulas, so that it can extract only the sheet name.
Below is the formula that will give you only the sheet name when you use it in any cell in that sheet:
=RIGHT(CELL("filename"),LEN(CELL("filename"))-FIND("]",CELL("filename")))
The above formula will give us the sheet name in all scenarios. And the best part is that it would automatically update in case you change the sheet name or the file name.
Note that the CELL formula only works if you have saved the workbook. If you haven’t, then it would return a blank (as it has no idea what the workbook path is)
Wondering how this formula works? Let me explain!
The CELL formula gives us the whole workbook address along with the sheet name at the end.
One rule it would always follow is to have the sheet name after the square bracket (]).
Knowing this, we can find out the position of the square bracket, and then extract everything after it (which would be the sheet name)
And that’s exactly what this formula does.
The FIND part of the formula looks for ‘]’ and return it’s position (which is a number that denotes the number of characters after which the square bracket is found)
We use this position of the square bracket within the RIGHT formula to extract everything after that square bracket
One major issue with the CELL formula is that it’s dynamic. So if you use it in Sheet1 and then go to Sheet2, the formula in Sheet1 would update and show you the name as Sheet2 (despite the formula being on Sheet1). This happens as the CELL formula considers the cell in the active sheet and gives the name for that sheet, no matter where it is in the workbook. A workaround would be to hit the F9 key when you want to update the CELL formula in the active sheet. This will force a recalculation.
Alternative Formula to Get Sheet Name (MID formula)
There are many different ways to do the same thing in Excel. And in this case, there is another formula that works just as well.
Instead of the RIGHT function, it uses the MID function.
Below is the formula:
=MID(CELL("filename"),FIND("]",CELL("filename"))+1,255)
This formula works similarly to the RIGHT formula, where it first finds the position of the square bracket (using the FIND function).
It then uses the MID function to extract everything after the square bracket.
Fetching Sheet Name and Adding Text to it
If you’re building a dashboard, you may want to not just get the name of the worksheet, but also append a text before or after it.
For example, if you have a sheet name 2021, you may want to get the result as ‘Summary of 2021’ (and not just the sheet name).
This can easily be done by combining the formula we saw above with the text we want before it using the ampersand operator.
Below is the formula that will add the text ‘Summary of ‘ before the sheet name:
="Summary of "&RIGHT(CELL("filename"),LEN(CELL("filename"))-FIND("]",CELL("filename")))
The ampersand operator (&) simply combines the text before the formula with the result of the formula. You can also use the CONCAT or CONCATENATE function instead of an ampersand.
Similarly, if you want to add any text after the formula, you can use the same ampersand logic (i.e., have the ampersand after the formula followed by the text that you want to append).
So these are two simple formulas that you can use to get the sheet name in Excel.
I hope you found this tutorial useful.
Other Excel tutorials you may also like:
- How to Rename a Sheet in Excel (4 Easy Ways + Shortcut)
- How to Insert New Worksheet in Excel (Easy Shortcuts)
- How to Unhide Sheets in Excel (All In One Go)
- How to Sort Worksheets in Excel using VBA (alphabetically)
- Combine Data From Multiple Worksheets into a Single Worksheet in Excel
- How to Compare Two Excel Sheets
- How to Group Worksheets in Excel