VBA Lesson 20: VBA for Excel StatementsThis is an excerpt from Pierre Leclerc (www.excel-vba.com) Among the VBA statements yu will discover If, Then, ElseIf, End If, Do, Loop, For, Next, While, With, the powerful "Select Case" statement and others. A lot of visitors ask us how they can delete the entire lines when a certain cell is empty. First enter xxx where you want the loop to stop. Select the cell at the top of the column and run this macro. Sub proDelete() Do Until Selection.Value = "xxx" Range("A1").Select End Sub Exiting a Loop In the loop above if you want the loop to stop when it finds the value 99 you can add this line of code within the loop: Exit allows you to get out of almost anything like: Go to the next lesson |