SWAY14
New Member
- Joined
- Jul 27, 2022
- Messages
- 15
- Office Version
- 2019
- 2016
- 2013
- Platform
- Windows
- MacOS
Hello,
So I have a macro which deletes the entire row if the date is less than current date. it works fine but the thing is on windows machine I get "delete method of range class failed" since if there is cells with that do not have todays date. But I need it to get out of the loop if this is the case not throw an error. on Mac I do not have this issue.
My code
Sub STEP2()
Application.DisplayAlerts = False
Dim cell As Range
For Each cell In Worksheets("Sheet2").Range("A1:A1000")
If cell.Value < Date Then
cell.EntireRow.Delete
End If
Next cell
End Sub
Any help with be grateful
So I have a macro which deletes the entire row if the date is less than current date. it works fine but the thing is on windows machine I get "delete method of range class failed" since if there is cells with that do not have todays date. But I need it to get out of the loop if this is the case not throw an error. on Mac I do not have this issue.
My code
Sub STEP2()
Application.DisplayAlerts = False
Dim cell As Range
For Each cell In Worksheets("Sheet2").Range("A1:A1000")
If cell.Value < Date Then
cell.EntireRow.Delete
End If
Next cell
End Sub
Any help with be grateful