Hide rows based on data validation dropdown list.

holz_001

New Member
Joined
Oct 29, 2019
Messages
5
Hi,

I am looking to hide/unhide rows based on a drop down validation.

The below codes works for one drop down however I have a further 2 drop downs that need to hide different rows.

any help will be greatly appreciated.

Private Sub Worksheet_Change(ByVal Target As Range)
'Updated by Extendoffice 20180822
If Target.Column = 9 And Target.Row = 5 Then
If Target.Value = "No" Then
Application.Rows("52:62").Select
Application.Selection.EntireRow.Hidden = True
ElseIf Target.Value = "Yes" Then
Application.Rows("52:62").Select
Application.Selection.EntireRow.Hidden = False
End If
End If
End Sub
 

Some videos you may like

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
41,087
Office Version
365
Platform
Windows
How about
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    If Target.Address(0, 0) = "I5" Then
        Rows("52:62").Hidden = Target.Value = "No"
    ElseIf Target.Address(0, 0) = "[COLOR=#ff0000]J5[/COLOR]" Then
        Rows("[COLOR=#ff0000]65:70[/COLOR]").Hidden = Target.Value = "No"
    End If
End Sub
Change address & rows in red to suit
 

Watch MrExcel Video

Forum statistics

Threads
1,099,775
Messages
5,470,709
Members
406,718
Latest member
waseem11

This Week's Hot Topics

Top