View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
kkknie[_201_] kkknie[_201_] is offline
external usenet poster
 
Posts: 1
Default renaming worksheets with a macro


The errors were caused because you cannot use wildcards like that.

Worksheets("UV??_??_????_0") would be looking for a worksheet with the
name UV??_??_????_0 which doesn't exist.

Not sure why the like didn't work...

Here's code to do what you want:

Sub renameum()

Dim s As Worksheet

For Each s In Worksheets
If InStrRev(s.Name, "_") 0 Then
s.Name = "Sheet" & Right(s.Name, Len(s.Name) - InStrRev(s.Name,
"_"))
End If
Next

End Sub

K


--
kkknie
------------------------------------------------------------------------
kkknie's Profile: http://www.excelforum.com/member.php...fo&userid=7543
View this thread: http://www.excelforum.com/showthread...hreadid=265554