Apr 11 2022 06:50 AM
Hello,
I wanted to hide the collumns(G2:NG2) that came before the date of today(D2).
So for example, today 11/04/2022. All the dates before that should be hidden
But so far I got this:
Dim rng As Range Set rng = ActiveSheet.Range("G2:NG2") For Each cell In rng If Month(cell) = Month(Date) Then Columns(cell.Column).Hidden = True End If Next cell
But it doesn't work the way I want.
Apr 11 2022 07:07 AM
SolutionLike this:
Dim rng As Range
Dim cell As Range
Application.ScreenUpdating = False
Set rng = ActiveSheet.Range("G2:NG2")
For Each cell In rng
If cell.Value < Date Then
cell.EntireColumn.Hidden = True
Else
Exit For
End If
Next cell
Application.ScreenUpdating = True
Apr 11 2022 07:07 AM
SolutionLike this:
Dim rng As Range
Dim cell As Range
Application.ScreenUpdating = False
Set rng = ActiveSheet.Range("G2:NG2")
For Each cell In rng
If cell.Value < Date Then
cell.EntireColumn.Hidden = True
Else
Exit For
End If
Next cell
Application.ScreenUpdating = True