mgchurch77
New Member
- Joined
- Aug 15, 2011
- Messages
- 33
I have the following code embedded with a worksheet that hides a column based on a cell reference.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Sheets("Report Data").Range("H39").Value < 2 Then
Columns("C:E").EntireColumn.Hidden = True
Else
Columns("C:E").EntireColumn.Hidden = False
End If
End Sub
What should this look like if I then want to also hide columns F:H if the value is greater than or equal to 2? So basically, if less than 2 hide C:E but show all else (including F:H), if greater than or equal to 2 hide F:H, then show all else (including C:E).
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Sheets("Report Data").Range("H39").Value < 2 Then
Columns("C:E").EntireColumn.Hidden = True
Else
Columns("C:E").EntireColumn.Hidden = False
End If
End Sub
What should this look like if I then want to also hide columns F:H if the value is greater than or equal to 2? So basically, if less than 2 hide C:E but show all else (including F:H), if greater than or equal to 2 hide F:H, then show all else (including C:E).