Hi, I need to hide a variety of rows dependent on the selection from a dropdown. Very new to VBA and tried the below from another forum which seems to work but only for the last line of code. Each time I add another line for another of the dropdown options the previous one stops working so probably something very basic.
Thanks in advance!
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("C8")) Is Nothing Then
With Range("$C$8")
Range("20:20,25:28,30:30,36:38").EntireRow.Hidden = .Value = "Option 1"
Range("20:20,25:28,30:30,37:38").EntireRow.Hidden = .Value = "Option 2"
Range("20:20,22:28,30:30,33:33,36:38").EntireRow.Hidden = .Value = "Option 3"
Range("20:20,24:26,28:28,33:33,36:37").EntireRow.Hidden = .Value = "Option 4"
Range("20:20,25:28,30:30,33:33,36:38").EntireRow.Hidden = .Value = "Option 5"
Range("20:20,28:28,30:30,36:36,38:38").EntireRow.Hidden = .Value = "Option 6"
Range("20:22,25:30,36:38").EntireRow.Hidden = .Value = "Option 7"
Range("25:27,30:30,36:38").EntireRow.Hidden = .Value = "Option 8"
Range("25:27,30:30,37:38").EntireRow.Hidden = .Value = "Option 9"
End With
End If
End Sub
Thanks in advance!