macro to hide data (with conditional formatting?)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a large spreadsheet and I want it to automatically HIDE a row if a
certain cell value meets a specific criteria. Does anyone know if this can be
done? I know I can do this manually but would like to automate if possible.

Thanks.
 
I believe this is what you are after. Right click the sheet tab where
you want this to take place and paste this (modify to suite):
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Text = "Freddy" Then _
Target.EntireRow.Hidden = True
End Sub

This will hide the target's row anytime Freddy is entered into it.
 
Or you can use something like this in the Workbook_Open event to hide
all rows in Sheet 1 where the value in column A is Freddy.
Private Sub Workbook_Open()
Dim r As Long
With Sheets("Sheet1")
.Rows.Hidden = False
For r = 2 To .Cells(.Rows.Count, 1).End(xlUp).Row
If .Cells(r, 1).Value = "Freddy" Then _
.Cells(r, 1).EntireRow.Hidden = True
'or .Rows(r).Hidden = True
Next r
End With
End Sub
 

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