Hi,

This is simple for all of you but I can't get it to work. Instead of the
user seeing a VBA error message, I'd like for the sub to end or for it to
skip down a few lines of code. How do I do this?

Thanks!

Re: If there's an error then Exit the Sub! by Vince

Vince
Wed Apr 06 20:14:37 CDT 2005

Sub Sample()
On Error GoTo ErrorDescription: ' Any error results in the program runnin
down to errordescription:

Dim i As Integer

i = "asjdaskdjasdjas" ' Error produced here (assinging string to integer)

GoTo ex:
ErrorDescription:
MsgBox "sorry dude, I have a problem: " & Err.Description

ex:
End Sub

OR

Sub Sample()
On Error resume next: ' No error message will be shown! Just goes to the
next ling
Dim i As Integer

i = "asjdaskdjasdjas" ' Error produced here (assinging string to integer)
msgbox "Hi" ' Hi will be output!


GoTo ex:
ErrorDescription:
MsgBox "sorry dude, I have a problem: " & Err.Description

ex:
End Sub

You can also do an Instr(err.description,"Type mismatch")<>0 or something
like that and trap all the errors and have something done for each case....


"Julia" <Julia@discussions.microsoft.com> wrote in message
news:DF4E4C74-F26E-40D5-992E-25825E2B7430@microsoft.com...
> Hi,
>
> This is simple for all of you but I can't get it to work. Instead of the
> user seeing a VBA error message, I'd like for the sub to end or for it to
> skip down a few lines of code. How do I do this?
>
> Thanks!
>
>



Re: If there's an error then Exit the Sub! by Julia

Julia
Thu Apr 14 14:19:18 CDT 2005

Thank you
>-----Original Message-----
>Sub Sample()
>On Error GoTo ErrorDescription: ' Any error results in
the program runnin
>down to errordescription:
>
>Dim i As Integer
>
>i = "asjdaskdjasdjas" ' Error produced here (assinging
string to integer)
>
>GoTo ex:
>ErrorDescription:
>MsgBox "sorry dude, I have a problem: " & Err.Description
>
>ex:
>End Sub
>
>OR
>
>Sub Sample()
>On Error resume next: ' No error message will be shown!
Just goes to the
>next ling
>Dim i As Integer
>
>i = "asjdaskdjasdjas" ' Error produced here (assinging
string to integer)
>msgbox "Hi" ' Hi will be output!
>
>
>GoTo ex:
>ErrorDescription:
>MsgBox "sorry dude, I have a problem: " & Err.Description
>
>ex:
>End Sub
>
>You can also do an Instr(err.description,"Type mismatch")
<>0 or something
>like that and trap all the errors and have something done
for each case....
>
>
>"Julia" <Julia@discussions.microsoft.com> wrote in message
>news:DF4E4C74-F26E-40D5-992E-25825E2B7430@microsoft.com...
>> Hi,
>>
>> This is simple for all of you but I can't get it to
work. Instead of the
>> user seeing a VBA error message, I'd like for the sub
to end or for it to
>> skip down a few lines of code. How do I do this?
>>
>> Thanks!
>>
>>
>
>
>.
>