Marco to delete rows with a future date

markman235

Board Regular
Joined
May 10, 2011
Messages
52
Hi everyone,

I am to write a macro for Excel 365 that will look at a date and delete the row if it is greater than today. I found one that was from a few years ago online, but it doesn't seem to work.

The date is in column F

Sub delfutureDays()
Dim cl As Long
For cl = Range("F2").End(xlDown).Row To 2 Step -1
If Cells(cl, "F") > Date Then Rows(cl).EntireRow.Delete
Next
End Sub

Any thoughts?

Mark
 
Then they are text (the aligning to the left is also a giveaway)

Try carrying out the steps below

  • Select the range in the column
  • Data tab
  • Text to Columns
  • Delimited
  • Next
  • Make sure all the checkboxes are cleared
  • Next
  • Select Date checkbox
  • Select the YMD option (yes YMD as you want the source format)
  • Click Finish
  • Format the cells as desired
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Then they are text (the aligning to the left is also a giveaway)

Try carrying out the steps below

  • Select the range in the column
  • Data tab
  • Text to Columns
  • Delimited
  • Next
  • Make sure all the checkboxes are cleared
  • Next
  • Select Date checkbox
  • Select the YMD option (yes YMD as you want the source format)
  • Click Finish
  • Format the cells as desired
Perfect! Thank you very much for all your help!!
 
Upvote 0

Forum statistics

Threads
1,221,527
Messages
6,160,342
Members
451,638
Latest member
MyFlower

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