OK.
try
Code:
Sub RenameSheet()
Dim Sht As Worksheet, ShtName As String, NewShtName As String
On Error Resume Next
With Worksheets("Main")
'//new sheet name
ShtName = .Range("b2").Value
'//check the sheet is already exists
Set Sht = Worksheets(ShtName)
NewShtName = Evaluate("Xref!d2")
If Not Sht Is Nothing Then
Err.Clear
Sht.Name = NewShtName
If Not Err.Number = 0 Then
MsgBox "Sheet name '" & NewShtName & "' already exist"
Exit Sub
End If
.Columns(1).Replace ShtName, NewShtName, 1
Else
MsgBox "Sheet name '" & ShtName & "' not found"
End If
End With
End Sub
Bookmarks