I have a Drop Down list with Multiple Options to select from source C9:C100. I would like to hide all Rows from C9 onwards except for the chosen cells corresponding row in the drop down list. I have tried the below code however it does not work.
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("B4") = "True" Then
Rows("9:100").EntireRow.Hidden = False
Else
Rows("9:100").EntireRow.Hidden = True
End If
End Sub
Test if B4 has a value, if it has find the row number with MATCH and then hide the other rows.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim row As Variant
row = Application.Match(Range("B4").Value, Range("C9:C100"), 0)
If Not IsError(row) Then
Rows("9:100").Hidden = True
Rows(8 + row).Hidden = False
Else
Rows("9:100").Hidden = False
End If
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.