# Need help Finishing code.

##### Board Regular
i need to find out how to finish this code. but im having trouble with just 2 parts of it. the Do until Statement, and the function to Fill a cell with the color red.

Code:
``````x = 4

Do until (end of sheet)
If Cells(x, 1) = "" Than
Cells(x, 1) (fill in box red)
x = x + 9
Loop

any help would be greatly appreciated.``````

### Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

#### Joe4

##### MrExcel MVP, Junior Admin
If you just want it to down to the last row with data, try:
Code:
``````    Dim x As Long
Dim myLastRow As Long

'   Find last row of column A
myLastRow = Cells(65536, 1).End(xlUp).Row

x = 4

Do Until x > myLastRow
If Cells(x, 1) = "" Then Cells(x, 1).Interior.ColorIndex = 3
x = x + 9
Loop``````
If you want to do all rows, then change myLastRow to 65536 (no formula).

##### Board Regular
Thank you so much. was perfectly what i needed.

#### HalfAce

##### MrExcel MVP
Along with jm14's, example, here are a couple more that work too.
Code:
``````Dim x As Long, LstRw As Long
x = 4
LstRw = Cells(Rows.Count, 1).End(xlUp).Row
While x < LstRw
If Cells(x, 1) = "" Then Cells(x, 1).Interior.ColorIndex = 3 '(fill in box red)
x = x + 9
Wend``````

And . . .
Code:
``````Dim x As Long, LstRw As Long
LstRw = Cells(Rows.Count, 1).End(xlUp).Row
For x = 4 To LstRw Step 9
If Cells(x, 1) = "" Then Cells(x, 1).Interior.ColorIndex = 3 '(fill in box red)
Next x``````

And lastly, if these cells are the only blank cells in column A (used range) then you can
do it without looping at all.
Code:
``````Dim LstRw As Long
LstRw = Cells(Rows.Count, 1).End(xlUp).Row
Range(Cells(4, 1), Cells(LstRw, 1)).SpecialCells(xlCellTypeBlanks).Interior.ColorIndex = 3``````

Replies
1
Views
85
Replies
1
Views
146
Replies
4
Views
96
Replies
3
Views
157
Replies
3
Views
189

1,186,328
Messages
5,957,232
Members
438,295
Latest member
nm005

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

### Which adblocker are you using?

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

### Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back