I have the following code:
I need to be able to exit the sub if 1.) no department is entered or 2.) if cancel button is pushed
I have tried a few things but they do not work or they simply are not allowed or understood. The last thing I tried was to check to see if the TabName was blank and then simply exit.
Thanks for any help!
Code:
Function TabIs(TName As String) As Boolean
On Error Resume Next
TabIs = Worksheets(TName).Name = TName
On Error GoTo 0
End Function
Sub SelectSheet()
' Variable
Dim TabName As String
'Check for Department and prep to move to that sheet
Do Until TabIs(TabName)
TabName = InputBox("Enter Department")
If Not TabIs(TabName) Then MsgBox TabName & " does not exist in workbook", , "Sheet Name Does Not Exist"
Loop
If TabName = "" Then Exit Sub
'Jump to sheet
Sheets(TabName).Select
End Sub
I have tried a few things but they do not work or they simply are not allowed or understood. The last thing I tried was to check to see if the TabName was blank and then simply exit.
Thanks for any help!