I'm playing around with the code sample below.
Sub Hide_Columns_Containing_Value()
Dim c As Range
Dim ThisIsToday As Date
Dim TwoWeeksBack As Date
Dim ThreeMonthsAhead As Date
ThisIsToday = Date
TwoWeeksBack = ThisIsToday - 14
ThreeMonthsAhead = ThisIsToday + 100
For Each c In Range("O4:XA4").Cells
If c.Value < TwoWeeksBack Or c.Value > ThreeMonthsAhead Then
Range(c.Address).Select
Selection.ColumnWidth = 1.75
Else
c.EntireColumn.Hidden = True
End If
Next c
End Sub
Basically I want to loop through all cells and if the value is a date less than two seeks ago, or more than 3 months from now, I want to hide the column. The problem is that the dates are not in every cell; the dates are in every 7 cells, which represent every Friday. The hiding and showing of columns is not working like I want it to, because of all the blank cells.
Here is a screen shot of the dates.