Excel ProcessWorkbook

D

dar

Below is code I got from here: However, some columns were inserted and
now the code does not work.
Basically, I want to delete rows that have a Date less than today .
I wish I could find my original question/answer that I must have posted back
in January.

Sub ProcessWorkbook()
Dim bk As Workbook, sh As Worksheet
Dim rng As Range, lastrow As Long
Set bk = Workbooks.Open("N:\ClinicTECList.xls")
For Each sh In bk.Worksheets
lastrow = sh.Cells(Rows.Count, 4).End(xlUp).Row
For i = lastrow To 1 Step -1
Set rng = sh.Cells(i, 4)
If Not IsEmpty(rng) Then
If IsDate(rng) Then
If rng < Date Then
rng.EntireRow.Delete
End If
End If
End If
Next
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top