Hi,
I have an excel file in which one row is for one date. The dates are in column A in descending order ie A3= 31-12-2025, A4=30-12-2025, A5=29-12-2025...etc waybackwards till 01-01-2021. I am using this code to hide rows which have date greater than current date. It works, but it takes a long time to complete. How can this be rewritten so that this code runs faster. The code is placed in the Worksheet_Activate event. (Sheet2.Range("A1").Value will always be the current date.)
Sub GetDate2()
Sheet1.Range("A3:A1828").Select
Selection.EntireRow.Hidden = False
Dim i As Long
For i = 1828 To 3 Step -1
If Sheet1.Range("A" & i).Value > Sheet2.Range("A1").Value Then Sheet1.Range("A" & i).EntireRow.Hidden = True
Next i
End Sub
TIA
I have an excel file in which one row is for one date. The dates are in column A in descending order ie A3= 31-12-2025, A4=30-12-2025, A5=29-12-2025...etc waybackwards till 01-01-2021. I am using this code to hide rows which have date greater than current date. It works, but it takes a long time to complete. How can this be rewritten so that this code runs faster. The code is placed in the Worksheet_Activate event. (Sheet2.Range("A1").Value will always be the current date.)
Sub GetDate2()
Sheet1.Range("A3:A1828").Select
Selection.EntireRow.Hidden = False
Dim i As Long
For i = 1828 To 3 Step -1
If Sheet1.Range("A" & i).Value > Sheet2.Range("A1").Value Then Sheet1.Range("A" & i).EntireRow.Hidden = True
Next i
End Sub
TIA