Hello VBA Gurus,
Yet again I unsuccessfully tried to write VBA code. Can you guys please let me know what is wrong with this code. I am simply trying to hide all columns in range E3 to PZ3 if the dates in these are less than the date in C1 or greater than the date in D1.
Yet again I unsuccessfully tried to write VBA code. Can you guys please let me know what is wrong with this code. I am simply trying to hide all columns in range E3 to PZ3 if the dates in these are less than the date in C1 or greater than the date in D1.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xCell As Range
If Target.Address <> Range("C1").Address Or Target.Address <> Range("D1") Then Exit Sub
Application.ScreenUpdating = False
For Each xCell In Range("E3:PZ3")
If xCell < Range("C1") Or xCell > Range("D1") Then
xCell.EntireColumn.Hidden = True
End If
Next
Application.ScreenUpdating = True
End Sub