Exceltechie.com

Easiest way to learn excel on the planet
Facebook-exceltechie Twitter-exceltechie Linkedin-exceltechie
|| Novice || Beginner || Intermediate || Advanced || Specialist || Expert ||

VBA Loops Loops are used in Excel VBA Macro code to tell Excel to repeat a block of code until a condition is TRUE, FALSE, a specified number of times. Details on Looping functions Definitive loop

For loop Conditional loop - DO While loop Step into the code only when a condition is met Warning Common mistakes : Loop condition does not meet and hence the code keeps running and you keep staring the screen
Do [statements] [Exit Do] [statements] Loop [{While | Until} condition]

For...Next Loop Syntax For counter = Start To end [Step step] [statements] [Exit For] [statements] Next [counter]
Conditional loop -do until
Common mistakes : Loop condition does not meet and hence the code keeps running and you keep staring the screen


Since the checking is made at the end of the loop, the Do Until Loop always iterates at-least once s for each
Typically used for objects such as sheet etc..
Select Case
Select Case Case < Range1> to Statements Case < Range2> to Statements Case Is Statements Case Else Statements End Select