![]() |
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 |
Macro error
In the VBE, go to Tools=Options and in the General tab make sure you have
selected Break on Unhandled errors instead of Break on All Errors. -- Regards, Tom Ogilvy "Chance224" wrote in message ... 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 |
Macro error
Break on unhandled errors is selected.
"Tom Ogilvy" wrote: In the VBE, go to Tools=Options and in the General tab make sure you have selected Break on Unhandled errors instead of Break on All Errors. -- Regards, Tom Ogilvy "Chance224" wrote in message ... 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 |
Macro error
My omission
this should do it: Sub SelectSheet() Dim sh As Worksheet 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 -- Regards, Tom Ogilvy "Chance224" wrote in message ... Break on unhandled errors is selected. "Tom Ogilvy" wrote: In the VBE, go to Tools=Options and in the General tab make sure you have selected Break on Unhandled errors instead of Break on All Errors. -- Regards, Tom Ogilvy "Chance224" wrote in message ... 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 |
All times are GMT +1. The time now is 12:05 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com