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

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
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
Loop through the LDCol range to find the rows where "LD" appears.
Build new ranges that exclude the rows containing "LD" by dynamically adjusting the size of each range.
Redefine your ranges with the rows where "LD" is not present.
 
Upvote 0

Forum statistics

Threads
1,224,744
Messages
6,180,697
Members
452,994
Latest member
Janick

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