I am trying to create a script that hides or unhides specific Columns when a value is entered into a Column using VBA.
For instance, if X is entered into any cell in Column A then hide Columns B:C. But if the value in Column A is Y then Columns D:E but show Columns B:C.
This is what I've tried thus far:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("A").Value = "X" Then
Columns("B:C").EntireColumn.Hidden = True
ElseIf Range("A").Value = "Y" Then
Columns("D:E").EntireColumn.Hidden = True
Else
End If
End Sub