Try this:
Sub Rename()
Dim ws As Worksheet, wsCheck As Worksheet
Dim strName As String
Application.ScreenUpdating = False
For Each ws In Worksheets
If IsDate(ws.Range("B2").Value) Then
strName = Format(ws.Range("B2").Value, "mm-dd-yyyy")
Else
strName = ws.Range("B2").Value
End If
Set wsCheck = Nothing
On Error Resume Next
Set wsCheck = Sheets(strName)
If wsCheck Is Nothing Then
ws.Name = strName
Else
MsgBox ("The sheet " & strName & " already exists. Click OK to continue.")
End If
On Error GoTo 0
Next ws
Application.ScreenUpdating = True
End Sub
Bookmarks