It's might be going into error because a sheet doesn't exist with that name which leads to a bigger question. Why on earth are you asking if an existing sheets name, has a name, which is it's name? Of course it is it's name.
It would be like going up to my friend Bob and saying; "Bob, if your name is Bob can you please pass me a beer".
If you are just trying to see if a sheet name exists there are other ways around it. Here is an example;
Sub test()
Dim wkshtcheck As Worksheet
Set wkshtcheck = Nothing
On Error Resume Next
Set wkshtcheck = Sheets("NonExistentWorksheet")
On Error GoTo 0
If wkshtcheck Is Nothing Then
MsgBox ("worksheet not found")
Else
MsgBox ("worksheet found")
End If
End Sub
Bookmarks