ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   On Error and Loops (https://www.excelbanter.com/excel-programming/331254-error-loops.html)

ThisShouldBeEasy

On Error and Loops
 
If I exit a loop do to an error (On Error) can I then direct control back
into the loop via a GoTo?

e.g.

On Error GoTo EndofProc

For i = 0 to n
Resume:
' do stuff
Next i

Exit Sub

EndofProc:
i = i + 1
GoTo Resume



JE McGimpsey

On Error and Loops
 
one way:

On Error GoTo EndofProc
For i = 0 To n
'Do Stuff
Continue:
Next i
Exit Sub
EndofProc:
'do error stuff
Resume Continue
End Sub


In article ,
"ThisShouldBeEasy" wrote:

If I exit a loop do to an error (On Error) can I then direct control back
into the loop via a GoTo?

e.g.

On Error GoTo EndofProc

For i = 0 to n
Resume:
' do stuff
Next i

Exit Sub

EndofProc:
i = i + 1
GoTo Resume



All times are GMT +1. The time now is 02:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com