Hi everyone,
I'm relatively new to VBA's so need a bit of help please...
I'm looking to hide columns L through to Q when cell 'S1' returns 0 and unhide them all again when it goes blank. I've managed to use the below code to get this to work -
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("S1").Value = 0 Then
Columns("L").EntireColumn.Hidden = True
Columns("M").EntireColumn.Hidden = True
Columns("N").EntireColumn.Hidden = True
Columns("O").EntireColumn.Hidden = True
Columns("P").EntireColumn.Hidden = True
Columns("Q").EntireColumn.Hidden = True
Else
Columns("L").EntireColumn.Hidden = False
Columns("M").EntireColumn.Hidden = False
Columns("N").EntireColumn.Hidden = False
Columns("O").EntireColumn.Hidden = False
Columns("P").EntireColumn.Hidden = False
Columns("Q").EntireColumn.Hidden = False
End If
End Sub
However I need another criteria in there too. If cell 'T1' returns 0 I would like to hide column P only and unhide when the cell goes blank. Both cells won't return 0 at the same time. I've tried adding another IF but seems to fail.
Any help would be appreciated!
Bookmarks