If you want to auto fill color specific range using for loop VBA. In this article you will learn for loop in VBA meeting certain condition.
The idea is if range A1:A20 contains anything text or number then excel for loop will auto fill the blank cells.
Following is the snapshot of data in column A:
To automatically fill the color in blank cells, we need follow the below steps:
Sub VBAForLoop()
For x = 1 To 20
Cells(x, 1).Select
If Selection.Value = "" Then
With Selection.Interior
.Color = 65535
End With
End If
Next x
End Sub
In this way we can use VBA to auto fill color using for loop.
Download-How to Auto Fill color with vba for loop
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.