View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Philip Philip is offline
external usenet poster
 
Posts: 156
Default Setting the CodeName of a new worksheet in the VBE Editor

Thanks all,

In the end I found it was fairly simple like this:
thisworkbook.VBProject.VBComponents("Sheet1").Name = "Phil"

Philip

"Norman Jones" wrote:

Hi Philip,

To change the sheet's codename, try something like:

'=============
Public Sub Tester()
ThisWorkbook.VBProject.VBComponents _
(Worksheets("Sheet2").CodeName).Name = "aName"
End Sub
'<<=============


---
Regards,
Norman


"Philip" wrote in message
...
Hi,

When I programatically add a new worksheet in VBA, is there a way to
programatically set the CodeName property ...

So instead of showing as Sheet1 in the VB Editor 'Project Explorer', the
new
sheet shows as what I want it to be.

This is for Excel 2003

thanks for any help

Philip