Worksheet CodeName

D

Drew Lettington

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
 
B

Bob Phillips

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.
 

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