How to works with loop using excel vba

Published: 20 May 2020
on channel: VBA Learning tutorials
39
2

How to works with loop using excel vba

Sub UsingForloop()

Dim i As Integer
For i = 1 To 10
Sheet1.Range("A" & i).Value = i

Next i
End Sub

Sub UsingForEachLoop()

Dim cell As Range
Dim rng As Range
Set rng = Sheet1.Range("A1:A10")

For Each cell In rng
cell.Interior.Color = vbCyan
Next cell

End Sub

Sub UsingDoLoop()

Dim i As Integer
i = 1
Do
Sheet1.Range("B" & i).Value = i
i = i + 1
Loop

End Sub

Sub UsingDowhileLoop()

Do While ActiveCell.Value not equl to ""

ActiveCell.Offset(0, 2).Value = "Number Found"
ActiveCell.Offset(1, 0).Select
Loop

End Sub

Sub UsingDountilLoop()

Do Until ActiveCell.Value = ""

ActiveCell.Offset(0, 2).Value = "Number Found"
ActiveCell.Offset(1, 0).Select
Loop

End Sub


Watch video How to works with loop using excel vba online without registration, duration hours minute second in high quality. This video was added by user VBA Learning tutorials 20 May 2020, don't forget to share it with your friends and acquaintances, it has been viewed on our site 3 once and liked it people.