Excel Formula To Display The Sheet Name In A Cell - KING OF EXCEL

KING OF EXCEL

KINGEXCEL.INFO ( KING OF EXCEL ) Welcome KINGEXCEL.INFO - Nothing Is Unable ... About Excel Tricks, Learning VBA Programming, Dedicated Software, Accounting, Living Skills ...

Sunday, April 26, 2020

Excel Formula To Display The Sheet Name In A Cell

Excel Formula To Display The Sheet Name In A Cell

This blog post looks at using an Excel formula to display the sheet name in a 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 name.
For the formula we will be using the CELL, MID and FIND functions. Let’s begin by looking at the CELL function.
The CELL function is a fantastic, and relatively unknown, function in Excel. Its purpose is to return information about a cell such as its column, cell colour, whether it is in a protected state or the filename.We need to use the function to return the filename of a cell. Because our goal is to return the sheet name, it does not matter what cell we use. Any cell on the sheet will work. In the example below, cell B1 has been used.
=CELL("filename",B1)
The function above will return the full filename of the cell such as;
C:\Users\Trainee1\Desktop\[return-sheet-name.xlsx]London

Extracting Just the Sheet Name

Now that we have the filename, we need to extract just the sheet name. The MID and FIND functions 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 following characters are those for the sheet name.
The 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.
Here is the full Excel formula to display the sheet name in a cell;
=MID(CELL("filename",B1),FIND("]",CELL("filename",B1))+1,32)

Watch the Video




No comments:

Post a Comment