excelnoobhere
Board Regular
- Joined
- Mar 11, 2019
- Messages
- 61
I have the following code that looks at AC1 and renames the tabs in the entire workbook based on the cell value and if there is no name or any unacceptable characters it gives an error message. I want this to happen only for the active sheet and not to loop through each sheet. I know it is just a one line change but I'm not sure how. I would still like to keep all the error checking and messages.
thanx in advance
thanx in advance
Code:
Sub tabname()Dim ws As Worksheet
For Each ws In Worksheets
On Error Resume Next
If Len(ws.Range("AC1")) > 0 Then
ws.Name = ws.Range("AC1").Value
End If
On Error GoTo 0
If ws.Name <> ws.Range("AC1").Value Then
MsgBox ws.Name & " The sheet was Not renamed, the suggested name was invalid"
End If
Next
End Sub