Do-loop
Do-loop
Do-loop
1
REVISION
2
File:
Do-loop: Selecting Data DoLoop_example.xlsx
Expected to learn:
Do-while loop
• Description: If-then-else
• Create a macro that scans data Interior.Color
VbRed
in column C starting from row
number 4 using a Do-While Comments
loop. If the value in the cell is Indentation
greater than 100%, highlight ThisWorkbook.Sheets
the cell in red. Set
RGB(255, 0, 0)
• Learn from the given program
(generated by ChatGPT) and Self-learning:
improve your code. Do Loop While
Do Loop Until
Do Until Loop
Cells() will return a
Range Object
Range Object
Sub test_DoWhileLoop()
Dim i As Long
i=4
Do While Cells(i, 1).Value <> ""
If Cells(i, 3).Value >= 1 Then
Cells(i, 3).Interior.Color = vbRed
End If
i=i+1
Loop
End Sub Color value
4
Sub HighlightValuesOver100Percent()
Dim ws As Worksheet
Dim rowNum As Long Row number:
Long
Code
Dim currentValue As Double
End If
Loop
End Sub