I am using the code below to hide a column based on a cell value.
I need to repeat this macro from column C to column AF.
How do I need to modify it to avoid copying this code for each colum?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("C5").Value = 0 Then
Columns("C").EntireColumn.Hidden = True
Else
Columns("C").EntireColumn.Hidden = False
End If
End Sub
Thanks
I need to repeat this macro from column C to column AF.
How do I need to modify it to avoid copying this code for each colum?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("C5").Value = 0 Then
Columns("C").EntireColumn.Hidden = True
Else
Columns("C").EntireColumn.Hidden = False
End If
End Sub
Thanks