View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Find the next Cell with interior color using Do Until...Loop

Possible

Sub FindLastRow()
Dim LastRow As Long
Dim i As Long
For i = ActiveCell.Row To 65536
If Cells(i, 2).Interior.ColorIndex = 40 Then
MsgBox Cells(i, 2).Address
Exit Sub
End If
Next
End Sub

Mike

"RyanH" wrote:

I need a macro to scan down Col. B from the ActiveCell to find the next cell
that is hightlighted orange ( .Interior.ColorIndex = 40). Here is what I
got, but it does not seem to work.

Sub FindLastRow()

Dim LastRow As Long
Dim i As Long

Do
For i = ActiveCell.Row To ActiveCell.Row + 30
LastRow = Cells(i, 2).Row
Next i
Loop Until Cells(i, 2).Interior.ColorIndex = 40

MsgBox "LastRow = " & LastRow

End Sub

Thanks in Advance,
Ryan