Reset on error
Hi all,
I am trying to exit a loop or go to a certain place in the procedure once an error has been found. It works fine on the first iteration but the second time it doesn't recognise the on error commmand. Below is the piece of code. thanks in advance.
Sub FindTable()
startloop:
'Find first table
Selection.GoTo What:=wdGoToTable, Which:=wdGoToFirst, Count:=1, Name:=""
'If can not find any more tables exit loop
On Error GoTo endloop:
Selection.Tables(1).Cell(1, 1).Select
'If can not find row 2 column 3 go to local handler
On Error GoTo LocalHandler:
Selection.Tables(1).Cell(2, 3).Select
LocalHandler:
'Reset on error
On Error GoTo 0
GoTo startloop:
endloop:
End Sub
|