Remove duplicates after date

bouncey

New Member
Joined
Jan 13, 2010
Messages
35
Hi,

I have the following code
Code:
Sub datesorting()
  For i = Range("g" & Rows.Count).End(xlUp).Row To 2 Step -1
If (Cells(i, "h").Value <> "" And Cells(i, "h").Value <= Cells(i, "g").Value) Then Cells(i, "h").EntireRow.Delete
  Next i
End Sub

Is there any way of still running the above code but excluding todays date and before (column H)?

All help appreciated.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
At first glance replace your If line with:
Code:
With Cells(i, "h")
  If (.Value <> "" And .Value <= Cells(i, "g").Value And .Value > Date) Then .EntireRow.Delete
End With
I haven't tested this but I suspect there might be trouble with converting date values to Long type or some such, depending a little on what is in the date cells in your worksheet.
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,850
Members
452,948
Latest member
UsmanAli786

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