Look at the attached workbook for 2 macros. One will hide or show columns and rows based on today's date. The other one will unhide all columns and rows so you can work on your table.
Here is the code:
Public Sub HIde_OR_Show()
Dim C_ell As Range, Col_Rng As Range, Proj_is_due As Boolean
Dim Row_Rng As Range
Application.ScreenUpdating = False
'Lets start with the columns
For Each Col_Rng In Range("B1", Cells(1, Columns.Count).End(xlToLeft))
Proj_is_due = False
For Each C_ell In Range(Col_Rng.Offset(1), Cells(Rows.Count, Col_Rng.Column).End(xlUp))
If C_ell >= Int(Now()) And C_ell < Int(Now()) + 7 Then
Proj_is_due = True
End If
Next
If Proj_is_due Then
Col_Rng.EntireColumn.Hidden = False
Else
Col_Rng.EntireColumn.Hidden = True
End If
Proj_is_due = False
Next
'Here we do the rows
For Each Row_Rng In Range("A2", Cells(Rows.Count, 1).End(xlUp))
Proj_is_due = False
For Each C_ell In Range(Row_Rng.Offset(0, 1), Cells(Row_Rng.Row, Columns.Count).End(xlToLeft))
If C_ell >= Int(Now()) And C_ell < Int(Now()) + 7 Then
Proj_is_due = True
End If
Next
If Proj_is_due Then
Row_Rng.EntireRow.Hidden = False
Else
Row_Rng.EntireRow.Hidden = True
End If
Proj_is_due = False
Next
Application.ScreenUpdating = True
End Sub
Public Sub Unhide_All()
Cells.EntireRow.Hidden = False
Cells.EntireColumn.Hidden = False
End Sub
Bookmarks