Hello,
I have a code to look up and go to a sheet name, it functions as intended but the cancel button does not work.
Can someone please tell me how to either make the cancel button work to cancel the command or to end the loop with out getting a error message
Below is the code
Thank you
I have a code to look up and go to a sheet name, it functions as intended but the cancel button does not work.
Can someone please tell me how to either make the cancel button work to cancel the command or to end the loop with out getting a error message
Below is the code
Thank you
Code:
Function WorksheetExists(WSName As String) As Boolean
On Error Resume Next
WorksheetExists = Worksheets(WSName).Name = WSName
On Error GoTo 0
End Function
Sub GotoSheet()
Dim shname As String
Do Until WorksheetExists(shname)
shname = InputBox("Enter Tank Code")
If Not WorksheetExists(shname) Then MsgBox shname & " Tank Code Doesn't Exist in File", vbExclamation
Loop
Sheets(shname).Select
End Sub