Re: If there's an error then Exit the Sub!
- From: "Vince" <sdsad@xxxxxxx>
- Date: Thu, 7 Apr 2005 09:14:37 +0800
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@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:DF4E4C74-F26E-40D5-992E-25825E2B7430@xxxxxxxxxxxxxxxx
> 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!
>
>
.
- Follow-Ups:
- Re: If there's an error then Exit the Sub!
- From: Julia
- Re: If there's an error then Exit the Sub!
- References:
- If there's an error then Exit the Sub!
- From: Julia
- If there's an error then Exit the Sub!
- Prev by Date: If there's an error then Exit the Sub!
- Next by Date: Documents referencing a ~tmp file ?
- Previous by thread: If there's an error then Exit the Sub!
- Next by thread: Re: If there's an error then Exit the Sub!
- Index(es):
Relevant Pages
|