I am trying to hide columns when a cell is changed. The Cell "C6" contains a list populated through data validation. I have put the following code in to worksheet change but the code runs when any cell is changed and i only want it to run when cell "C6" is changed
any ideas?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False
ActiveSheet.Unprotect
For Each c In Range("E1:AZ1")
If c.Value Like "0" Then
c.EntireColumn.Hidden = True
Else
c.EntireColumn.Hidden = False
End If
Next c
Application.ScreenUpdating = True
ActiveSheet.Protect
End Sub
any ideas?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False
ActiveSheet.Unprotect
For Each c In Range("E1:AZ1")
If c.Value Like "0" Then
c.EntireColumn.Hidden = True
Else
c.EntireColumn.Hidden = False
End If
Next c
Application.ScreenUpdating = True
ActiveSheet.Protect
End Sub