CodeName Property

Applies To

Chart object, Workbook object, Worksheet object.

Description

Returns the code name for the object. Read-only String.

Remarks

The code name for an object can be used in place of an expression that returns the object. For example, if the code name for worksheet one is "Sheet1", the following expressions are identical:

Worksheets(1).Range("a1")
Sheet1.Range("a1")
It's possible for the sheet name to be different from the code name. When you create a sheet, the sheet name and code name are the same, but changing the sheet name doesn't change the code name, and changing the code name (using the Properties window in the Visual Basic Editor) doesn't change the sheet name.

Example

This example displays the code name for worksheet one.

MsgBox Worksheets(1).CodeName