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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top