Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 18
Default Macro for renaming worksheets

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

  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 18
Default Macro for renaming worksheets

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
"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


  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 3,290
Default Macro for renaming worksheets

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

  #4   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 18
Default Macro for renaming worksheets

Thank you very much for the reply. I do appreciate it.

Joe

"Jim Cone" wrote in message
...
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


  #5   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 18
Default Macro for renaming worksheets

Jim,
thank you for the assistance, this code worked beautifully.

Joe

"Jim Cone" wrote in message
...
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Renaming worksheets Teeny Excel Discussion (Misc queries) 8 August 18th 09 10:21 PM
RENAMING WORKSHEETS LEOPARDSHIDEAWAY Excel Worksheet Functions 1 July 26th 07 10:27 PM
renaming worksheets/objects in VBA scottydel Excel Worksheet Functions 2 July 22nd 07 09:36 PM
Renaming worksheets Mike Allen Excel Discussion (Misc queries) 8 January 21st 07 02:15 AM
Renaming Worksheets Steve Walford Excel Worksheet Functions 3 April 1st 05 09:29 PM


All times are GMT +1. The time now is 11:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"