VBA delete rows with older dates but not rows with blank cells

morkar

New Member
Joined
Mar 8, 2021
Messages
10
Office Version
  1. 365
Platform
  1. Windows
Hello, I am trying to delete rows with older dates (older than 60 days) in column L but the macro below also deletes rows with blank values in that column. How can I adjust the macro so it does not delete the rows with blank values?


Sub DeleteOldTerms()
Dim lr As Long, I As Long
With Sheets("ExportedData")
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
lr = Range("L" & Rows.Count).End(xlUp).Row
For I = lr To 4 Step -1
If Range("L" & I).Value <= Date - 60 Then Rows(I).Delete
Next I
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End With
End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Try

VBA Code:
Sub DeleteOldTerms()
Dim lr As Long, I As Long
With Sheets("ExportedData")
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
lr = Range("L" & Rows.Count).End(xlUp).Row
For I = lr To 4 Step -1
If Range("L" & I).Value <= Date - 60 Then
    If Range("L" & I).Value <> "" Then Rows(I).Delete
    End If
End If
Next I
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End With
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,978
Messages
6,122,549
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top