Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Break Keyword

Status
Not open for further replies.

sanjna000

Programmer
Aug 1, 2003
132
GB
Hi guys,
I need to get rid from my loop when a particular statement is executed. Usually I use "Break" keyword in other programming lang. For VBA what we can use? I am new to VBA and I really need u r help!
Thanks guys,
Sanjna...
 
EXIT is the keyword but it depends on the type of loop
straight from VBA help (that's the thing brought up by pressing F1 btw)

Exit Statement

Exits a block of Do…Loop, For...Next, Function, Sub, or Property code.

Syntax

Exit Do

Exit For

Exit Function

Exit Property

Exit Sub

The Exit statement syntax has these forms:

Statement Description
Exit Do Provides a way to exit a Do...Loop statement. It can be used only inside a Do...Loop statement. Exit Do transfers control to the statement following the Loop statement. When used within nested Do...Loop statements, Exit Do transfers control to the loop that is one nested level above the loop where Exit Do occurs.
Exit For Provides a way to exit a For loop. It can be used only in a For...Next or For Each...Next loop. Exit For transfers control to the statement following the Next statement. When used within nested For loops, Exit For transfers control to the loop that is one nested level above the loop where Exit For occurs.
Exit Function Immediately exits the Function procedure in which it appears. Execution continues with the statement following the statement that called the Function.
Exit Property Immediately exits the Property procedure in which it appears. Execution continues with the statement following the statement that called the Property procedure.
Exit Sub Immediately exits the Sub procedure in which it appears. Execution continues with the statement following the statement that called the Sub procedure.

Remarks

Do not confuse Exit statements with End statements. Exit does not define the end of a structure.


Rgds, Geoff

"Having been erased. the document thjat you are seeking. Must now be retyped"

Please read FAQ222-2244 before you ask a question
 
Thanks Geoff, I really appriciate u r help!
Cheers,
Sanjna
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top