Thread: Macro error
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Chance224 Chance224 is offline
external usenet poster
 
Posts: 21
Default Macro error

If you cancel the inputbox or enter in a invalid name it goes to debug. Here
is the macro I'm using:

Sub SelectSheet()
res = InputBox("Enter employee (sheet) name")
On Error Resume Next
Set sh = Worksheets(res)
On Error GoTo 0
If sh Is Nothing Then
MsgBox res & " isn not a valid sheet name"
Else
sh.Activate
End If
End Sub

Thanks,
Chance