Error trapping

D

David

Hi Group,

I am having a hard time trapping an error and doing what I want to do next.

I am looking up values on a worksheet and it is possible that the value will
be "#N/A". I am comparing two values and the "#N/A" could be one of those
values, so beta(b) = ERROR 2042.

I would like to check if beta(b) does equal ERROR 2042 and then go to the
bottom of my loop.

Thanks for your help.
David
 
J

JP

You might want to post the code you're currently using. If I
understand your problem correctly, you want to trap Err.Number 2042.
There are (at least) two ways to do it. The simplest way is to use On
Error Resume Next before the "problem statement" (the one likely to
cause the error) then check if the error occurred.

Ex:

On Error Resume Next
x = x / 0
If Err.Number = 2042 Then
' take action if error occurs
End If
On Error GoTo 0


HTH,
JP
 
D

David

Hi JP,

If IsError(alpha(a)) Then
AlphaErrorCt = AlphaErrorCt + 1
GoTo erroralpha
End If

Hope that helps.

Thanks,
David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top