How to Insert Excel Sheet Name from Cell Value (3 Easy Ways)

Method 1 – Combining MID, CELL, and FIND Functions to Insert the Sheet Name into Cell Value

Consider the following dataset. We want to insert the Excel sheet name Mark as the salesman’s name.

Steps:

  • Select cell B5.
  • Insert the formula in cell B5.
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,256)

Combining MID, CELL, and FIND Functions to Insert Excel Sheet Name from Cell Value

Showing Results for Combining MID, CELL, and FIND Functions

Showing Results for Combining MID, CELL, and FIND Functions


Method 2 – Using the INDIRECT Function to Add Excel Sheet Name to Cell Value

We want to know the number of laptops sold by different salespeople. We have different sheets, each referring to a salesperson and containing their sales record. The sheet names are inserted in cells B6 and B7. We will extract the number of laptops sold from different Excel sheets using this Excel sheet name as cell values.

Steps:

  • Choose cell C5 and insert the formula.
=INDIRECT(B5&"!D5")

Using INDIRECT Function to Add Excel Sheet Name from Cell Value

  • By pressing Enter, you will get the value of cell D5 from the sheet named John.
  • In a similar way, you can get the value for the sheet named Antony.

Showing Results for Using INDIRECT Function


Method 3 – Applying VBA Code to Insert a Sheet Name from Cell Value in Excel

We will name the sheet as the name of the salesperson in cell B5.

Sample Data Set for Applying VBA Code to Insert Sheet Name from Cell Value in Excel

Steps:

  • Right-click on the sheet name from the sheet name tab and select View Code.

Applying View Code Option to Insert Sheet Name from Cell Value in Excel

  • A new window named Visual Basic for Applications will appear. Insert the following code in this window.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set Target = Range("B6")
If Target = " " Then Exit Sub
Application.ActiveSheet.Name = VBA.Left(Target, 31)
Exit Sub
End Sub
  • Save the window and close it.

Applying VBA Code to Insert Sheet Name from Cell Value in Excel

  • The sheet name will be changed to the value of cell B5.

Showing Results for Applying VBA Code


Download the Practice Workbook


Related Articles


<< Go Back to Excel Sheet Name | Excel Worksheets | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Prantick Bala
Prantick Bala

PRANTICK BALA is a marine engineer who loves exploring Excel and VBA programming. Programming, to him, is a time-saving tool for efficiently managing data, files, and internet tasks. He is proficient in Rhino3D, Maxsurf, C++, MS Office, AutoCAD, Excel, and VBA and goes beyond the basics. Armed with a B.Sc in Naval Architecture & Marine Engineering from BUET, he has transitioned into the role of a content developer. Beyond his work, find him immersed in books, exploring new... Read Full Bio

2 Comments
  1. Hi! I would like to have a month in sheets, would it be possible to have all the sheets somehow linked so I would have an easier time to change the dates than manually double click every sheet whenever I need to change the month?

    • Hi MIRA,
      It’s a great pleasure that you are watching our articles. You have a query regarding this article. You want to make an Excel sheet, where the dates of the Excel sheet will change according to the sheet name. Yes, you can do this. Read the below steps to get your solution.

      Steps:
      ● First, take an Excel sheet with the Date and Attendance columns.
      Data set
      We will insert dates in the Date column based on the Sheet Name.
      ● Before that, we will form a table that consists of the month’s name and serial number.
      Create Table
      ● Now, go to Cell E5 and put in the following formula.

      =MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,256)
      Formula to get Sheet name

      It will extract the name of the Sheet which is a month name.

      Formula Explanation:
      CELL(“filename”,A1)
      This finds the location of the Excel file with the Sheet name.
      Result:
      D:\Alok\[Excel-Sheet-Name-From-Cell-Value.xlsx]January

      FIND(“]”,CELL(“filename”,A1))
      This will find out the location of the symbol mentioned in the formula from the location.
      Result: 47

      FIND(“]”,CELL(“filename”,A1))+1
      Add 1 with the previous result.
      Result: 48

      MID(CELL(“filename”,A1),FIND(“]”,CELL(“filename”,A1))+1,256)
      Separate the sheet name from the location.
      Result: January

      ● After that, put the following formula on Cell F5.
      =INDEX(Month,MATCH(E5,Month[Month],0),2)

      Use of INDEX MATCH functions
      This returns the serial number of the month comparing the values of the table.
      ● Now, use the DATE function on Cell B5.

      =DATE(2022,$F$5,1)
      Use of Date Function

      ● Fill up the Date and Attendance columns.
      Fill Up two columns

      ● Now, change the sheet name from January to February and look at the changes that take place in the Date column.
      Change sheet name

      Download File:
      Solution.xlsx
      Regards.
      – Alok Paul
      Author at ExcelDemy

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo