Need a little Macro ...

K

Ken

Excel 2000 ... I have several WorkBooks from 2003 where
many TabSheet Names contain "2003".

For those TabSheets that do contain "2003" ... I would
like a Macro that would look at TabSheet Name & if name
contains "2003" change it to "2004".

As always ... Thank you to the many Excel Magicians that
support this board ... Kha
 
J

Jason Morin

Press ALT+F11, Insert > Module, insert the code below, and
then run the macro:

Sub Change2003()

Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets
With ws
If .Name Like "*2003*" Then
.Name = Application.WorksheetFunction _
.Substitute(.Name, "2003", "2004")
End If
End With
Next ws

End Sub
 
K

Ken

Perfect example of why I come to the many highly respected
Excel Magicians on this board ... Thanks ... Kha
 
J

JE McGimpsey

One way:

Public Sub Change2003To2004()
Dim wkSht As Worksheet
For Each wkSht In Worksheets
With wkSht
If .Name Like "*2003*" Then _
.Name = Replace(.Name, "2003", "2004")
End With
Next wkSht
End Sub
 

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

Top