Forum Discussion
A_SIRAT
Oct 29, 2023Iron Contributor
Help Edit a vba code
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 ne...
- Oct 29, 2023
Thank you !
It works perfectly.
HansVogelaar
Oct 29, 2023MVP
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 SubA_SIRAT
Oct 29, 2023Iron Contributor
Thank you !
It works perfectly.