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 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.
Thank you !
It works perfectly.
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
- A_SIRATIron Contributor
Thank you !
It works perfectly.