Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|