Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

In Excel, what's the difference between Name and (Name)? 4

Status
Not open for further replies.

jsteph

Technical User
Oct 24, 2002
2,562
US
Hi all,
If I go into the vba project listing in excel, and get the Properties for a sheet, there's (Name) at the top and then Name towards the bottom. The bottom one is what shows in the 'tab' section of the sheet, ie if you rename the tab, for example from Sheet1 to "Test" the (Name) stays "Sheet1" nd the Name "Test".

So the question is...why the ambiguity and confusion? In code how would one refer to one name or the other (name)?

I ask because I changed the (Name) via the properties window from Sheet1 and Excel 2007 crashed. Not sure it was directly related but it made me wonder.
--Jim
 
(Name) is the sheet's CodeName

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Here is an experiment that may (?) shed some light.

Change the top name "(name)"to SheetTop.
Change the middle name "name" to SheetMiddle.

Look at the project explorer and you'll see "SheetTop (SheetMiddle)"

If you try to access
Sheets("SheetTop").range("A1")
you'll get error - out of range

If you try to access
Sheets("SheetTop").range("A1")
you'll get error range("A1")


Look at the excel worksheet tabs and you'll see it is labeled SheetMiddle

So the location SheetMiddle seems to be the important one. The other one's purpose... I don't know. What's a codename?
 



FYI,

As a matter of course, I change all the sheet CodeNames as such...
[tt]
wsSheet_Name (Sheet Name)
[/tt]
In my code, I always refer to the CodeName and not the Name, as it is possible for users to change sheet Name, but not the CodeName.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Good point Skip.

And I do get the idea behind the separate entities but in my opinion the entities should have been called "CodeName" and "Name" and not "(Name)" and "Name", that's all.
--Jim
 


Where do you see "(Name)" and "Name"?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Where do you see "(Name)" and "Name"?
In the properties sheet of the Sheet object (F4 in VBE)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks everybody for this one. All this time, I've just used.... WorkSheet.Name to reference the name. But now I'll look into using the Code Name, or perhaps that's what I'm already using, just didn't realize it..

Regardless, interesting discussion, I'll have to read up on it a bit more.
 



Open a NEW workbook, plain vanila sheet1...
Code:
With Sheets("Sheet1")
'...
With Sheet1
'...
result in the same thing

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top