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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
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,415
Messages
6,119,375
Members
448,888
Latest member
Arle8907

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