Oct 29 2023 12:24 AM
Hi,
I got this code from the Internet which works pretty well. However, I would like to create an exception in what it does. The vba code renames the sheet names using a specific cell value. I need the code to be edited so it will also omit a sheet name that I do not want it to be renamed. At the moment, if there is any valid value on Cell F3, renaming will occur. If cell F3 is blank or >0, then it will give a message that the specific sheet has not been renamed....
Thanks in advance.
Oct 29 2023 12:59 AM
Sub tabname()
Dim ws As Worksheet
For Each ws In Worksheets
On Error Resume Next
Select Case ws.Name
Case "Exception 1", "Exception 2"
' Skip these sheets
Case Else
If Len(ws.Range("F3")) > 0 Then
ws.Name = Replace(ws.Range("F3").Value, "/", "-")
End If
On Error GoTo 0
If ws.Name <> Replace(ws.Range("F3").Value, "/", "-") Then
MsgBox ws.Name & " Was Not renamed, the suggested name was invalid"
End If
End Select
Next ws
End Sub
Oct 29 2023 01:09 AM - edited Oct 29 2023 01:09 AM
SolutionThank you !
It works perfectly.