How to Find Worksheet Name Code in Microsoft Excel
This super simple Excel tutorial can help you understand worksheet name code and How to Find Worksheet Name Code in Microsoft Excel
. Often, you import raw data from external sources in Excel and perform data analysis to generate insights. To import such external data, there is a dedicated worksheet. Let’s assume it is named “ProjectX_January01”.
The name clearly indicates that the worksheet contains raw data for “January 1st”. You or your organization have made it a habit to rename the worksheet to “ProjectX_January02” when you get data for the next day. Or, you have set up data import automation and the code automatically renames the worksheet name based on the date of the data.
Now, if there is an underlying Excel VBA script to create a pie chart that references this worksheet using “ProjectX_January01”, then the next day the script will not work because it has been renamed to “ProjectX_January02” and no one has updated the new worksheet name into the VBA script.
Here is the sheet name code, sheet code name, or (Name) object in Excel. If you refer to the sheet’s (Name) value instead of the sheet name, the script will work properly regardless of whether the sheet name is renamed.
WordPress Responsive Mega Menu Plugin Groovy Mega Menu Plugin
What is the sheet name code in Excel?

How to Find Worksheet Name Code in Microsoft Excel Sheet name code is the object name on the Excel VBA editor. When you create multiple worksheets, charts, and VBA modules in a workbook, the VBA editor assigns different (Name) codes to these objects. The (Name) code starts with Sheet1 for a worksheet and Chart1 for a chart.
In contrast, there is a Name property in all workbook objects, such as worksheets and charts. This is the same as the sheet tab name. When you rename a sheet from a sheet tab, the object’s Name property changes.

When you access the VBA code for a worksheet, you will see that the actual object (worksheet or chart) name is a combination of the (name) code and the name property. For example, Sheet1 (My Worksheet) in the example above.
Typically, you can manually change the display name of an Excel workbook object. Doing so does not change the (name) code. However, you can also change the (Name) code if you want, but you cannot access it if you are a beginner to intermediate Excel user.
If you are an Excel expert, you can change the worksheet name code. Therefore, as an Excel expert user, when writing Excel VBA scripts that reference worksheets, you should use the (Name) code instead of the Name property. Even if someone renames the worksheet, the Excel VBA script will still be able to reference the old worksheet name through the (Name) code.
Excel VBA Worksheet Names and Codes
See the following table to understand the difference between worksheet names and worksheet codes:
Characteristics | Worksheet Name | Worksheet Code |
Location | It is item 10 in the object property sheet in the Excel VBA Editor. | It is item 1 in the object property sheet in the Excel VBA Editor. |
Assigned to | Assigned in the VBA Editor. | Assigned in the Properties window. |
Purpose | To refer to a worksheet programmatically, regardless of its front end or user interface. It is a unique identifier for a VBA reference to an object. | This is the name of the worksheet that appears above the Excel status bar (sheet tab). This is the display name that appears for user interface clarity. |
Effect | The worksheet display name for the sheet tab will not change if you change the (Name) code. | The worksheet display name changes in the sheet tab when you change the Name property. Changing the sheet name does not affect VBA scripts that reference the sheet code. |
Use in VBA script | If the worksheet name code is Worksheet1, you can use it directly in VBA script, as shown in the following code: Sheet1.Range("A1").Value = "Hello, World!" | If the worksheet name is Worksheet1, you can reference it in Excel VBA as follows: ThisWorkbook.Sheets("Sheet1") |
How to Search for Anything on TikTok
Steps to find the worksheet name code in Excel
How to Find Worksheet Name Code in Microsoft Excel Open the Excel workbook and go to the worksheet for which you want to get the worksheet name code.

Right-click on the sheet name tab and select the View Code option from the context menu.

The Excel VBA Editor will open with the current worksheet as the selected object.
Look carefully at the worksheet property sheet. You should see two name rows: (Name) and Name.
The first, (name), is the Excel VBA code for the worksheet. The second, name, is the name of the worksheet you see on the sheet tab.


To change the sheet name code, double-click on the text, such as Sheet1, and start typing the new code on your keyboard. Hit Enter to save the sheet code name.
How to Use Sheet Name Codes in Excel VBA
Suppose you want to print “Hello, World!” in cell A1 in your worksheet. Here is an Excel VBA script that does this by referencing the sheet name in the workbook:

Sub sheetcode()
Set ws = ThisWorkbook.Sheets("Sheet1")
ws.Range("A1").Value = "Hello, World!"
End Sub
Now, if you change the sheet name to Sheet2 from the sheet tab, you will get the following error:

How to Find Worksheet Name Code in Microsoft Excel However, if you use the following VBA script by referencing the worksheet code in the workbook, the VBA macro will work regardless of how the worksheet name changes:

Sub sheetcode()
XYS.Range("A1").Value = "Hello, World!"
End Sub