A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Hi,
That's what you asked for. On encountering 10 blank cells the macro should terminate. A coloured cell that has nothing in it is blank as far as excel is concerned This will now terminate if it encounters 10 non coloured cells that also have nothing in them.
Sub HideRows()
Dim r As Range, Blankcount As Long
Dim s As String, v As Variant
Blankcount = 0
s = "Apple,Banana,Pineapple"
v = Split(s, ",")
For Each r In Selection
If r.Interior.Color = 16777215 And Len(r) = 0 Then
Blankcount = Blankcount + 1
Else
Blankcount = 0
End If
If IsError(Application.Match(r.Value, v, 0)) And _
r.Interior.Color = RGB(0, 0, 0) Or r.Interior.Color = RGB(0, 51, 0) Or r.Interior.Color = RGB(17, 17, 17) Then
r.EntireRow.Hidden = True
End If
If Blankcount = 10 Then Exit Sub
Next
End Sub