Free Excel VBA Course #17 - Do While and Do Until Loop in Excel VBA

preview_player
Показать описание
In this video, I will cover the Do While and Do Until loops and how to use these in Excel VBA.

A ‘Do While’ loop allows you to check for a condition and run the loop while that condition is met (or is TRUE).

There are two types of syntax in the Do While Loop.
-- Do While
-- Do Until

In this video, I show you a really simple example of how you can loop through a range of cells and fill these with numbers.

#Excel #ExcelTips #ExcelTutorial
Рекомендации по теме
Комментарии
Автор

Nice, widely use function need such this kind of easy and effectively explanation, thanks for making simple

parmeshwarcctv
Автор

Thanks for the clear explanation, I have run into some issues when I run the loop. Here is the loop I have written.

Sub

Dim i As Integer

For i = Selection.Rows.Count To 4 Step -1

Range("A4").Select
Selection.Offset(i + 3, 0).Select

Range("A4:A6").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With

'Remove the Merge Instruction tempoary
Selection.Merge
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With


Next i

End Sub

sernchiewhan
Автор

Superb explained brother.

Thanks...

pdbgatl
Автор

Very nice explained ❤️❤️❤️ but I changed something in yours code to give condition on time base but it's not working like I want to run a macro with interval of 5 mint from time 2 pm till 3 pm, really struggling for this, hope you will help me in this ❤️❤️❤️❤️

nvcworld
Автор

Hi,

I'm trying to figure out how to use Do While loops to copy and paste rows of data into a new worksheet. Any advice would be greatly appreciated. Thanks.

nicholasavis
Автор

Hi Sumit, nice video again, but I have one question, what is "If _ nothing" and "if not _ nothing statement" in VBA ??

KuldeepSingh-nqvi
Автор

Hi Sumit, I am Muhammad Naeem, one of your fans from pakistan. I have a problem in writing a VB code for invoice, may you guide me....?

MuhammadNaeem-wyzt