How to Use Do While Loop in Excel VBA? Last Updated : 30 Jul, 2021 Comments Improve Suggest changes Like Article Like Report A Do…While loop is used when we want to repeat certain set of statements as long as the condition is true. The condition may be checked at the starting or at the end of the loop Flowchart: Uses of Do-While loop: The Do While loop is used in two ways: Do…while loop which checks the condition at the STARTING of the loop.Do…while loop which checks the condition at the END of the loop. Syntax 1: Do While condition [statements] [Exit Do] [statements] Loop Syntax 2: Do While [statements] [Exit Do] [statements] Loop conditionImplementing a Do While loop: Follow the below steps to implement a Do-While loop: Step 1: Define a Macro Private Sub Demo_Loop() End Sub Step 2: Define variables j=2 i=1 Step 3: Write Do While Loop. You can write condition at the beginning or at the end Do While i < 5 Step 4: Write statements to be executed in loop msgbox "Table of 2 is : " & (j*i) i=i+1 Step 5: End loop. Now let's take a look at some of the examples. Example 1: Do…while loop which checks the condition at the STARTING of the loop. The below example uses Do…while loop to check the condition at the starting of the loop. The statements inside the loop are executed, only if the condition is True. We will print Table of 2 using Do...while loop; Private Sub Demo_Loop() j=2 i=1 Do While i < 5 msgbox "Table of 2 is : " & (j*i) i=i+1 Loop End Sub Output: Example 2: Do…while loop which checks the condition at the END of the loop. The below example checks the condition at the end of the loop. The major difference between these two syntax is explained in the following example. Private Sub Demo_Loop() i = 10 Do i = i + 1 MsgBox "The value of i is : " & i Loop While i < 3 'Condition is false.Hence loop is executed once. End Sub When the above code is executed, it prints the following output in a message box. Output: Comment More infoAdvertise with us Next Article How to Use Do While Loop in Excel VBA? A akshitsaxenaa09 Follow Improve Article Tags : Excel Excel-VBA ExcelGuide Similar Reads How to use While Wend Loop in Excel VBA? In this article, we are going to see about While Wend loop in Excel VBA using a suitable example. Implementation : In the Microsoft Excel tabs, select the Developer Tab. Initially, the Developer Tab may not be available. The Developer Tab can be enabled easily by a two-step process : Right-click on 2 min read How to use Do Until Loop in Excel VBA? In this article, we are going to see look into the Do Until loop in Excel VBA using a suitable example. Implementation : In the Microsoft Excel tabs, select the Developer Tab. Initially, the Developer Tab may not be available. The Developer Tab can be enabled easily by a two-step process : Right-cli 3 min read How to Use for Each Loop in Excel VBA? A For Each loop is used to execute a statement or a set of statements for each element in an array or collection. Syntax: For Each element In group [ statements ] [ Exit For ] [ statements ] Next [ element ] The For...Each...Next statement syntax has the following three parts: PartDescriptionelement 3 min read How to Use For Next Loop in Excel VBA? If you are familiar with the programming you must have an idea of what a loop is, In computer programming, a loop is a sequence of statements that are repeated until a specific condition is satisfied. In Excel VBA the "For Next" loop is used to go through a block of code a specific number of times. 4 min read How to Round With Doubles in Excel VBA The round function is used to round the floating numbers to a particular decimal value. Rounding a number, where it has a long decimal value will give a good balance between accuracy and readability. It also helps in calculation and also to get a precise result. In real life, it is useful in doing m 5 min read How to Use the VBA Immediate Window in Excel? The immediate window is similar to the console in Chrome, where we could execute the javascript. The immediate window allows us to execute macro code very fast and efficiently. Once, you learned it, you will always be found using it. Your immediate window can answer an infinite number of questions, 5 min read How to Use Solver in Excel? A solver is a mathematical tool present in MS-Excel that is used to perform calculations by working under some constraints/conditions and then calculates the solution for the problem. It works on the objective cell by changing the variable cells any by using sum constraints. Solver is present in MS- 3 min read Do While loop in Objective-C Just like other programming languages Objective-C also supports do..while loop. do..while loop is also known as an inverted while loop because, in a while loop, the expression is evaluated before executing the code present inside the body of the while loop, if the expression is false, then this loop 3 min read How to Set Variable to Cell Value in Excel VBA? Adding data to the worksheet is often done and it is essential to learn how to set variable to cell value in excel VBA. There can be instances when you want to add the same data to your worksheet. This task could easily be achieved with the help of Excel VBA variables. You can assign your cell value 5 min read How to use If-Else Statement in Excel VBA? VBA in Excel stands for Visual Basic for Applications which is Microsoft's programming language. To optimize the performance and reduce the time in Excel we need Macros and VBA is the tool used in the backend. In this article, we are going to learn how to use the If Else statement in Excel VBA. Impl 3 min read Like