Worksheet CodeName

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Based on a response to a previous post, I'm using Worksheet.CodeName to access a name for a worksheet that doesn't change if the user renames the sheet. However, I'm having problems getting my code to work...

First I created a workbook and added a macro that calls Excel.Worksheets.Add. I ran the macro a few times to create a few sheets and closed and saved the workbook. When I open the workbook again, my code loops through the worksheets collection, displaying the sheet name and code name - all the code names are blank. If I run the macro to create a new sheet and then loop through the worksheets collection again, sheet name and code name both display correctly.

Any ideas why I get this behavior?

- Drew
 
Drew,

Show the code to give us a chance.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

Drew Lettington said:
Based on a response to a previous post, I'm using Worksheet.CodeName to
access a name for a worksheet that doesn't change if the user renames the
sheet. However, I'm having problems getting my code to work...
First I created a workbook and added a macro that calls
Excel.Worksheets.Add. I ran the macro a few times to create a few sheets
and closed and saved the workbook. When I open the workbook again, my code
loops through the worksheets collection, displaying the sheet name and code
name - all the code names are blank. If I run the macro to create a new
sheet and then loop through the worksheets collection again, sheet name and
code name both display correctly.
 
Back
Top