#1   Report Post  
Posted to microsoft.public.excel.programming
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
Macro Run-time Error 1004 Application Defined or Object Defined Error Anddmx Excel Programming 6 June 9th 04 03:40 PM
Macro 'Automation error' with ChemOffice Excel macro Stew Excel Programming 0 October 27th 03 08:26 PM


All times are GMT +1. The time now is 03:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"