Renaming Sheets


Posted by Sam on July 23, 2001 9:05 AM

I have recently renamed all of my sheets and i have found that my macros have errors when running. i used the Sheets("Sheet1").Select format. I there any easy way to correct this without have to change "Sheets1" to the new custom name?

Thanks,
Sam

Posted by faster on July 23, 2001 9:29 AM

You could use the sheet position to reference it

Sheets(1).Select

But that still requires you change the code.



Posted by Ivan F Moala on July 23, 2001 6:13 PM

Sam
Just reference the sheets code name. In the
project explorer of the VBA editor
(Alt F11 then Ctrl R)
you will see something like this;

Sheet1(NewName1)
Sheet2(NewName2)
Sheet3(NewName3)

The name to the left of the brackets is the sheets
code name...this does not change even though you
change the sheets Tab name.....so reference it like so....

Sheets("NewName1").Select = Sheet1.Select
Sheets("NewName2").Select = Sheet2.Select
etc.

HTH

Ivan