Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / January 2008

Tip: Looking for answers? Try searching our database.

Macro for renaming worksheets

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joe - 14 Jan 2008 02:02 GMT
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
Joe - 14 Jan 2008 03:33 GMT
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.

> Good evening all,
>    I am trying to write a macro that renames the worksheets within a
[quoted text clipped - 4 lines]
>
> Joe
Jim Cone - 14 Jan 2008 04:36 GMT
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
Joe - 15 Jan 2008 01:10 GMT
Thank you very much for the reply. I do appreciate it.

Joe

> Sub NameThemPuppies()
> Dim sht As Object
[quoted text clipped - 27 lines]
> you in advance.
> Joe
Joe - 19 Jan 2008 18:08 GMT
Jim,
   thank you for the assistance, this code worked beautifully.

Joe

> Sub NameThemPuppies()
> Dim sht As Object
[quoted text clipped - 27 lines]
> you in advance.
> Joe
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.