Macro for renaming worksheets

J

Joe

Good evening all,
I am trying to write a macro that renames the worksheets within a
workbook. My problem is that the same worksheets don't always exist in every
workbook. I am trying to create the macro to use an If statement to skip
over the worksheet if it doesn't exist without halting on an error. Thank
you in advance.

Joe
 
J

Joe

Sorry for posting the same question twice. I am new to this type of forum
and didn't realize the first post had went through.

Joe
 
J

Jim Cone

Sub NameThemPuppies()
Dim sht As Object
For Each sht In Sheets
Select Case True
Case sht.Name = "Sheet1"
sht.Name = "Mush"
Case sht.Name = "Sheet2"
sht.Name = "Oatmeal"
Case sht.Name = "Sheet3"
sht.Name = "Corn Flakes"
Case sht.Name = "Sheet4"
sht.Name = "Cheerios"
End Select
Next 'sht
End Sub

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Joe"
wrote in message
Good evening all,
I am trying to write a macro that renames the worksheets within a
workbook. My problem is that the same worksheets don't always exist in every
workbook. I am trying to create the macro to use an If statement to skip
over the worksheet if it doesn't exist without halting on an error. Thank
you in advance.
Joe
 

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

Similar Threads

If statement 3
Macros 3
macro - replace 2
Help with Worksheet Merging Macro 13
Linking workbook to multiple worksheets 1
Appending worksheets 1
Protect and Unprotect all worksheets with macro 2
Key Board Shortcuts 4

Top