Changing of Sheet Codes for the worksheets...

R

RV

Hi,

I using the worksheet code obtained using CodeName property of the
worksheet object. Before saving the workbook, I just reshuffled the
worksheets in the workbook by moving them. Now if I just reopen this saved
workbook, to my surprise I found that the code name returned using
the CodeName property on worksheet object is different from that used to
returned when the workbook was opened first time.

I have found on other sites that CodeName for worksheet never changes.

Can anyone please clear my concept on the CodeName?

Thanks and With Warm Regads,

-Rahul Vakil
 
J

Joel

Read the VBA help menu on codename

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.

Note The value that you see in the cell to the right of (Name) in the
Properties window is the code name of the selected object. At design time,
you can change the code name of an object by changing this value. You cannot
programmatically change this property at run time.
 
D

Dave Peterson

Depending on security settings (trusting access to Visual basic project), the
codename can be changed.

dim wks as worksheet
set wks = thisworkbook.worksheets("aaa")
ThisWorkbook.VBProject.VBComponents(wks.codename).Name = "NewCodeName"
'or
ThisWorkbook.VBProject.VBComponents(wks.CodeName) _
.Properties("_CodeName").Value = "NewCodeName2"
Note The value that you see in the cell to the right of (Name) in the
Properties window is the code name of the selected object. At design time,
you can change the code name of an object by changing this value. You cannot
programmatically change this property at run time.
<<snipped>>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top