View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Alan Beban[_2_] Alan Beban[_2_] is offline
external usenet poster
 
Posts: 783
Default On Error GoTo : How to use multiple?

Thanks, Rob. I guess the exercise for me now is to figure out the
circumstances in which my erroneous approach will actually cause a
problem. The way the error handling blocks were set up was not just
happenstance.

Thanks again,
Alan Beban

Rob Bovey wrote:

Hi Alan,

Your procedure appears to work, but that's just a coincidence of the way
you structured it. If you place a watch on the Err object and single-step
through the code, you'll notice that any Resume statement you hit that
wasn't reached as a result of an error actually causes an error itself (Err
20: Resume without error).

Because of the way you set up the error handling blocks, however, this
error is simply caught by the error handler defined above it. The Resume
statement is then executed a second time as a result of the error, which is
OK, and it causes execution to resume at the specified line label.

To see the problem, try putting "length" and "east" in column B and "md"
in column A. Then comment out all of your On Error GoTo statements. If the
code was structured correctly, it should run without error, because the Find
method locates what it's looking for in every instance. However, you'll see
that the code actually bombs when it hits the first Resume statement. Under
the same conditions, Stephen's code will execute correctly.