(Solved) – VBA that will count number of rows until it hits a dark blue cell? (RGB = 93, 123, 157)

  • by
(solved)-–-vba-that-will-count-number-of-rows-until-it-hits-a-dark-blue-cell?-(rgb-=-93,-123,-157)

Starting in cell B8, I want to count the number of rows down until we hit a cell that is filled with the RGB 93, 123, 157.

I tried using the autofill formula feature while recording, but the cell references stayed absolute: Selection.AutoFill Destination:=ActiveCell.Range("A1:A182")

This will only work if the report has 182 rows, which they won’t all have.

I was also given this to try:

Sub Test()

Dim i As Long, bluerow As Long

For i = 1 To 10000
    If Cells(i, 2).Interior.Color = RGB(93, 123, 157) Then
        bluerow = i
        Exit For
    End If
Next i

Range("B6").AutoFill Destination:=Range("B6:B" & bluerow), Type:=xlFillDefault

End Sub

But it doesn’t put any numbers in column B.

Leave a Reply

Your email address will not be published. Required fields are marked *