I have a data validation list in cell B15. i want this piece of code to run when that cell is changed:
Private Sub Worksheet_change(ByVal Target As Range)
If Intersect(Target, Range("$B$15")) Is Nothing Then
Exit Sub
Else
Dim r As Range
Application.ScreenUpdating = False
For Each r In Range("E18:EE18")
r.EntireColumn.Hidden = (r.Value = "No")
Next
Application.ScreenUpdating = True
End If
End Sub
Basically, it should look to line 18 and hide columns where a "no" value is shown. It doesn't work because I have two "ranges" in this code. How do I get around that?
Thanks
Private Sub Worksheet_change(ByVal Target As Range)
If Intersect(Target, Range("$B$15")) Is Nothing Then
Exit Sub
Else
Dim r As Range
Application.ScreenUpdating = False
For Each r In Range("E18:EE18")
r.EntireColumn.Hidden = (r.Value = "No")
Next
Application.ScreenUpdating = True
End If
End Sub
Basically, it should look to line 18 and hide columns where a "no" value is shown. It doesn't work because I have two "ranges" in this code. How do I get around that?
Thanks