I have a spreadsheet where I am trying to make it hide multiple rows based on the values of specific cells. This works for the first set of values:
VBA code used:
Private Sub Worksheet_Change(ByVal Target As Range)
'Updated by Extendoffice 20180822
If Target.Column = 8 And Target.Row = 16 Then
If Target.Value = "No" Then
Application.Rows("17:19").Select
Application.Selection.EntireRow.Hidden = True
ElseIf Target.Value = "Yes" Then
Application.Rows("17:19").Select
Application.Selection.EntireRow.Hidden = False
End If
End If
End Sub
I have tried duplicating it so I could perform this function with multiple selections in the same sheet, however I do not know how to include it multiple times (I do not have a great working knowledge of VBAs).
I have tried to adjust it to the following:
Private Sub Worksheet_Change(ByVal Target As Range)
'Updated by Extendoffice 20180822
If Target.Column = 8 And Target.Row = 34 Then
If Target.Value = "No" Then
Application.Rows("35:37").Select
Application.Selection.EntireRow.Hidden = True
ElseIf Target.Value = "Yes" Then
Application.Rows("35:37").Select
Application.Selection.EntireRow.Hidden = False
End If
End If
End Sub
How would I mix it in?
Thanks.
VBA code used:
Private Sub Worksheet_Change(ByVal Target As Range)
'Updated by Extendoffice 20180822
If Target.Column = 8 And Target.Row = 16 Then
If Target.Value = "No" Then
Application.Rows("17:19").Select
Application.Selection.EntireRow.Hidden = True
ElseIf Target.Value = "Yes" Then
Application.Rows("17:19").Select
Application.Selection.EntireRow.Hidden = False
End If
End If
End Sub
I have tried duplicating it so I could perform this function with multiple selections in the same sheet, however I do not know how to include it multiple times (I do not have a great working knowledge of VBAs).
I have tried to adjust it to the following:
Private Sub Worksheet_Change(ByVal Target As Range)
'Updated by Extendoffice 20180822
If Target.Column = 8 And Target.Row = 34 Then
If Target.Value = "No" Then
Application.Rows("35:37").Select
Application.Selection.EntireRow.Hidden = True
ElseIf Target.Value = "Yes" Then
Application.Rows("35:37").Select
Application.Selection.EntireRow.Hidden = False
End If
End If
End Sub
How would I mix it in?
Thanks.