Hiding Rows - Conditional

  • Thread starter Thread starter Random NumNuts
  • Start date Start date
R

Random NumNuts

HI all,

I would like to have a macro that will hide rows based on their background
color. That is, some rows (yellow) need to be completed only for add-on
sales, while new sales (blue) require a different group. I know how to hide
specific rows, but not how to make it conditional. Is it possible?

Many thanks../RN
 
Hi
try something like the following:
Sub hide_rows()
Dim RowNdx As Long
Dim LastRow As Long

LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row
For RowNdx = LastRow To 1 Step -1
If Cells(RowNdx, "A").interior.colorindex=3 Then
Rows(RowNdx).hidden = True
End If
Next RowNdx
End Sub

hides all rows in column A with a colorindex=3 (red) -> change this to
your needs
 
Back
Top