How to Hide Rows based on conditional value in cell

N

Nick

Hi,

I have seen lots of examples but can't get any to work - I have a job
sheet with approx 60 rows - the rows contain data applicable to
various types of job.

What I want to do is have the user select which job type they are
completing, and then automatically hide/unhide the rows that aren't
relevant to that job.

I have added a hidden column A with an If statement that returns 1 or
0 depending on if the row should be shown/hidden 1 to show - 0 to
hide)based on what the user picks as the job type.

Can anyone help with some sample code and maybe advice on how I can
get this to work ?

Thanks..
Nick
 
Y

yogendra joshi

you can use worksheet_change event to control the same.

For example if you want to do this based on your hidden A row

Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range
Application.ScreenUpdating = False
For Each cell In Range("A5:A60")
If cell.Value = 0 Then
cell.EntireRow.Hidden = True
ElseIf cell.Value = 1 Then
cell.EntireRow.Hidden = False
End If
Next
Application.ScreenUpdating = True
End Sub
 
Top