Page 1 of 1

DO Loops Syntax in VBA

Posted: Tue Jun 09, 2020 3:34 am
by admin
x = 1

Do While x < 10
Cells(x, 1).Value = x
x = x + 1
Loop

-- Based on a condition to check cell value

x = 5

Do While Cells(x, 1).Value <> ""
Cells(x, 3).Value = Cells(x, 2).Value + 30
x = x + 1
Loop

-- Do Until

intRow = 1

Do Until IsEmpty(Cells(intRow, 1))

Cells(intRow, 1).Value = "ERPstuff"
intRow = intRow + 1
Loop

intRow = 1

-- Do where Until after loopo so once it will must execute
Do
Cells(intRow, 1).Value = "Info"
intRow = intRow + 1
Loop Until IsEmpty(Cells(intRow, 1))