View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Stephen Bullen[_3_] Stephen Bullen[_3_] is offline
external usenet poster
 
Posts: 74
Default On Error GoTo : How to use multiple?

Hi Alan,

Unfortunately, you can't sprinkle the Resume statements in the middle of the
code like that. If you want to use multiple error checks, you need to have
the error handlers at the bottom of the procedure to ensure the code doesn't
enter the error handler if there isn't an error:

Sub checkk()

Dim test1 As Boolean
Dim test2 As Boolean
Dim test3 As Boolean

check1:
On Error GoTo ErrCheck1
Columns("B").Find(What:="length").Activate
test1 = True

check2:
On Error GoTo ErrCheck2
tab1start = Columns("A").Find(What:="md").Row
test2 = True

check3:
On Error GoTo ErrCheck3
tab2start = Columns("B").Find(What:="east").Row
test3 = True

stopp:
If Not test3 Then
MsgBox "Unknown format"
End If

Exit Sub

'These are the error handlers for each test
ErrCheck1:
Resume check2

ErrCheck2:
Resume check3

ErrCheck3:
Resume stopp

End Sub


Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.ie