Do until cell is not equal to white colour?

sufianmalik

Board Regular
Joined
May 7, 2002
Messages
128
Is it possible to fill a series until a cell changes colour?

so i have a formula in cell C3 and the last cell maybe C400 but next week may change to C401 and i want the fill to look at the colour of cell C401 to determine when to stop?
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Try this.
Code:
Sub G()

    Dim i As Integer

    ' Check whether cell is not green.
    ' If cell is not green, stop loop and fill till this non-green cell.
    For i = 3 To 400
        If Range("C" & i).Interior.Color <> RGB(0, 255, 0) Then
            Exit For
        End If
    Next
    
    Range("C3").AutoFill Destination:=Range("C3:C" & i - 1)

End Sub
 
Upvote 0
thanks for your reply, i have a formula in cell DV4 so did the following, but it didn't like the range...any suggestions?



Sub G()

Dim i As Integer

' Check whether cell is not green.
' If cell is not green, stop loop and fill till this non-green cell.

For i = 3 To 400
If Range("DV" & i).Interior.Color <> RGB(0, 2, 0) Then
Exit For
End If
Next

Range("DV4").AutoFill Destination:=Range("DV4:D" & i - 1)

End Sub
 
Upvote 0
ok i noticed the error and corrected, but that turns cells DV1 DV2 etc white rather than filling

Sub G()

Dim i As Integer

' Check whether cell is not green.
' If cell is not green, stop loop and fill till this non-green cell.

For i = 3 To 400
If Range("DV" & i).Interior.Color <> RGB(0, 2, 0) Then
Exit For
End If
Next

Range("DV4").AutoFill Destination:=Range("DV4:DV" & i - 1)

End Sub
 
Upvote 0
In loop, adjust start value of variable "i" as the same row where your formula is located. For instance, if formula is in DV4, then:
Code:
For i = [COLOR="Red"][B]4[/B][/COLOR] To 400
Also white color would be RGB(255, 255, 255).
If you wanna check till cell HAS NOT filling, then check it against "xlNone" constant.
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

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?

Disable AdBlock

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
Back
Top