Problem with Last Row, then Deleting Specific Date Range

Guzzlr

Well-known Member
Joined
Apr 20, 2009
Messages
955
Office Version
  1. 2016
Platform
  1. Windows
Hello All
I have a large data set, and I'm trying to delete all rows in column A with the year of 2020 and before...basically leaving only 2021.
the data set is in the format (in column A) as: 2020-3-24:6_19_53 meaning 3-24-2020 with a time of hh:mm:ss or 6:19 and 53 seconds in the morning, on March 24, 2020
Also, Row 1 is a Header Row, and should not be deleted.

Below is the code I'm trying to use...and of course it's not working.
Can someone help please?
thanks for the help

VBA Code:
With Sheets("Spray Booth 1")
      With .Range("A2", .Range("A" & Rows.Count).End(xlUp))
         .AutoFilter 1, "=2020"
         .Offset(1).SpecialCells(xlVisible).EntireRow.Delete
      End With
      .AutoFilterMode = False
End With
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
How about
VBA Code:
With Sheets("Spray Booth 1")
      With .Range("A2", .Range("A" & Rows.Count).End(xlUp))
         .AutoFilter 1, "2020*"
         .Offset(1).SpecialCells(xlVisible).EntireRow.Delete
      End With
      .AutoFilterMode = False
End With
 
Upvote 0
How about
VBA Code:
With Sheets("Spray Booth 1")
      With .Range("A2", .Range("A" & Rows.Count).End(xlUp))
         .AutoFilter 1, "2020*"
         .Offset(1).SpecialCells(xlVisible).EntireRow.Delete
      End With
      .AutoFilterMode = False
End With
The **** Asterisk wildcard!
Works great!
Thanks for the help!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,494
Messages
6,125,139
Members
449,207
Latest member
VictorSiwiide

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