Excel Functions Tutorials

- VBA
- VBA Tutorial
- VBA Functions in Excel
- VBA ArrayList
- VBA Arrays Function in Excel
- VBA Activate Sheet
- VBA Break
- VBA Borders
- VBA Boolean
- VBA ByRef
- VBA Code
- VBA Const
- VBA Class Modules
- VBA Count
- VBA COUNTA
- VBA COUNTIF
- VBA Comment Block
- VBA Match Function
- VBA LEFT Function
- VBA Right Function
- VBA Like
- VBA LEN
- VBA Long
- VBA Today
- VBA Now
- VBA Time Function
- VBA Timer
- VBA TimeValue
- VBA Weekday
- VBA ROUND
- VBA RoundUp
- VBA Random Numbers
- VBA ReDIM Function
- VBA Rename Sheet
- VBA Protect Sheet
- VBA Remove Duplicates
- VBA Concatenate
- Copy Paste in VBA
- VBA Paste
- VBA Print
- VBA Date Function
- VBA DateDiff Function
- VBA DateAdd Function
- VBA DatePart
- VBA Data Type
- VBA Dictionary
- VBA Debug Print
- VBA Charts
- VBA CDBL
- VBA CSTR
- VBA Chr
- VBA ChDir
- VBA ENUM
- VBA RegEx
- VBA Mid Function
- VBA Max
- VBA Find Function
- VBA Find and Replace
- VBA Trim Function
- VBA Text
- VBA OFFSET Function
- VBA MOD Function
- VBA Split Function
- VBA UBound Function
- VBA Union
- VBA Transpose
- VBA INT
- VBA InStr
- VBA INSTRREV
- VBA Intersect
- VBA Integer
- VBA DIR Function
- VBA OR Function
- VBA AND
- VBA Operators
- VBA Not Equal
- VBA Worksheet Function
- VBA Workbook
- VBA ThisWorkbook
- VBA Worksheets
- VBA Write Text File
- VBA Hyperlinks
- VBA String Functions
- VBA StrComp
- VBA StrConv
- VBA Sub
- VBA Call Sub
- VBA End
- VBA Wait
- VBA Option Explicit
- VBA SubString
- VBA Subscript Out of Range
- VBA IIF
- VBA IF OR
- VBA IFERROR
- VBA On Error
- VBA OverFlow Error
- VBA 1004 Error
- VBA Error Handling
- VBA Type
- VBA Type Mismatch Error
- VBA IsEmpty
- VBA ISNULL
- VBA Input Box
- VBA MsgBox
- VBA Text Box
- VBA Format
- VBA Format Number
- VBA Conditional Formatting
- VBA AutoFill
- VBA AutoFilter
- VBA Color Index
- VBA Font Color
- VBA Clear Contents
- VBA Collection
- VBA Paste Special
- VBA Progress Bar
- VBA GoTo
- VBA Userform
- VBA Close UserForm
- User Defined Function in Excel VBA
- VBA Outlook
- VBA JOIN
- VBA LCase
- VBA UCase
- VBA Select Case
- VBA Select Cell
- VBA Selection
- VBA Active Cell
- VBA Set
- VBA Sleep
- VBA Pause
- VBA Range Objects
- VBA Range Cells
- VBA UsedRange
- VBA Loop
- VBA Break For Loop
- VBA For Each Loop
- VBA For Next Loop
- VBA Do Until Loop
- VBA File Copy
- VBA FileDialog
- VBA FileSystemObject (FSO)
- VBA Cells
- VBA Last Row
- VBA Insert Row
- VBA Hide Columns
- VBA New Line
- VBA GetOpenFilename
- VBA GetObject
- VBA Delete File
- VBA Delete Row
- VBA Insert Columns
- VBA Delete Column
- VBA Val
- VBA Value
- VBA Variant
- VBA Variable Declaration
- VBA Global Variables
- VBA Pivot Table
- VBA Refresh Pivot Table
- VBA PowerPoint
- VBA Send Email from Excel

- Financial Functions in Excel (17+)
- Logical Functions in Excel (15+)
- TEXT Functions in Excel (29+)
- Lookup Reference in Excel (44+)
- Maths Functions in Excel (52+)
- Date and Time Function in Excel (22+)
- Statistical Function in Excel (50+)
- Information Functions in Excel (5+)
- Excel Charts (48+)
- Excel Tools (98+)
- Excel Tips (178+)

Related Courses

## What is Do Until Loop in VBA Excel?

VBA Do Until Loop means do something until the condition becomes TRUE. It is like a logical function works based on TRUE or FALSE.

So if the condition is FALSE it will keep executing the statement inside the loop but if the condition is TRUE straight away it will exit the Do Until statement. This is the opposite of Do While loop where Do while runs the loops as long as the condition is TRUE.

### Syntax of VBA Do Until Loop

This VBA Do Until loop has two kinds of syntax.

**#1 – VBA Do Until Loop Syntax **

Do Until [condition] [Perform Some Task] Loop

**#2 – VBA Do Until Loop Syntax 2-**

Do [Perform Some Task] Loop Until [condition]

Both look very similar and there is one simple differentiation is there.

In the first syntax “Do Until” loop checks the condition first and get the condition result as TRUE or FALSE. If the condition is FALSE it will execute the code and perform a specified task and if the condition is TRUE then it will exit the loop.

In the second syntax “Do” loop firstly it will execute the cod task then it tests whether the condition is TRUE or FALSE. If the condition is FALSE it will again go back and perform the same task. If the condition is TRUE then it will straight away exit the loop.

### Example of VBA Do Until Loop

I know it is not that easy to understand anything in the theory part, but nothing to worry. We will give you easy examples to understand the loop. Read on. To start the learning, let’s perform the task of inserting the first 10 serial numbers from cell A1 to A10. Follow the below steps to apply the “Do Until” loop.

**Step 1: **Create a macro name first to start the subprocedure.

**Code:**

Sub Do_Until_Example1() End Sub

**Step 2: **Define a variable as **“Long”. ** I have defined “x” as a long data type.

Dim x As Long

**Step 3: **Now enter the word “Do Until”.

Do Until

**Step 4: **After starting the loop name enter the condition as “x =11”.

`Do Until x = 11`

x = 11 is the logical test we have applied. So this line says to run the loop until x is equal to 11.

**Step 5: **Apply CELLS property and let’s insert serial numbers from 1 to 10.

4.6 (247 ratings)

Cells(x, 1).Value = x

* Note:* Here we have mentioned “x” starts from 1, so at first x value is equal to 1. Wherever “x” is there is equal to 1.

**Step 6: **Now close the loop by entering the word “LOOP”.

Sub Do_Until_Example1() Dim x As Long Do Until x = 11 Cells(x, 1).Value = x Loop

End Sub

Ok, we are done with the coding part, now we will test the codes line by line to understand the loop better.

To run the line by line code first press F8 key.

It will first highlight the macro name by yellow color.

When you can see the yellow line it says that that is not executed by about to execute if you press F8 key one more time.

Now press F8 key one more time, the yellow line will go to Do Until Loop.

Now to understand the loop place a cursor on the variable “x” and see the value of variable “x”.

So, x=0. Since the highlighted line is the first line in the loop so the value of “x” is zero, so press F8 key once again and see the value of “x”. Before that exit the code running and assign the value to “x” as 1.

Now again start the running of a loop by pressing F8 key. See the value of “x”.

Now the value of “x” is showing as 1. To have incremental value to the variable “x” we need to reassign the value of variable “x” as x = x + 1 inside the loop.

Now press F8 key one more time and we should get the value of 1 in cell A1.

Now press F8 key once again and see what the value of “x” is.

The value of variable “x” is 2 now. So our condition says to run the loop until the condition becomes TRUE, so our loop keeps running until the value of “x” becomes 11.

Press F8 one more time it will jump back to the “Do Until” loop line.

Press F8 key two more times, we will get the value of 2 in cell A2.

Press F8 key again and the value of “x” becomes 3 now.

Press F8 key again it will jump back to the loop once again.

Like this, this loop will again keep executing the task until the value of “x” becomes 11. Now I have executed the loop until the “x” value becomes 11.

Now if I press F8 it still it will go back to the loop.

But if I press F8 key now it will exit the loop because the applied condition becomes “TRUE” i.e. x = 11.

So we have serial numbers from 1 to 10 in excel sheet now.

So, this is the basic idea of the “Do Until” loop. To understand any loops you need to run the code line by line until you get the full knowledge about loops.

You can download this VBA Do Until Excel Template from here – VBA Do Until Excel Template

### Recommended Articles

This has been a step by step guide to VBA Do Until Loop. Here we discuss how to use VBA Do Until Loop in Excel along with a practical example. Below are some useful excel articles related to VBA –

- VBA Count
- VBA Union Method
- Excel VBA ArrayList | Examples
- Examples of UCase Function in VBA
- Formula of VBA ENUM
- Excel Proper Formula
- Loops in VBA
- For Next Loop in VBA
- LEN in VBA
- Integer in VBA

- 3 Courses
- 12 Hands-on Projects
- 43+ Hours
- Full Lifetime Access
- Certificate of Completion