I intend to rename all the sheets with the cell "G2" value except the two sheets called "Main" and "Fixed".
The code keeps renaming the two sheets.
Sub RenameSheets()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
'With ActiveWorkbook.ActiveSheet
If ActiveWorkbook.ActiveSheet.Name <> "Main" Or _
ActiveWorkbook.ActiveSheet.Name <> "Fixed" Then
ws.Activate
If Range("G2").Value = "" Then
ActiveSheet.Name = Range("G2").End(xlDown).Value
Else: ActiveSheet.Name = Range("G2").Value
End If
Else:
GoTo Nextsv
End If
Nextsv: Next ws
Sheets("Main").Activate
ActiveSheet.Cells(1, 1).Select
End Sub