Sorting and deleting based on previous month

drozek

Board Regular
Joined
Aug 3, 2011
Messages
67
Column J has a ton of ship dates listed as '5/20/2019 and '10/14/2018 and so on. How would I write some code to filter and delete everything but the previous months ship date.

I run this report in June for May shipments, so I only want to see 5/*/2019 dates, but I run this everything so something like MM - 1, and this year?

Thanks!
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
OK so I figured out my date problem, now how do I delete everything that is not from last month.


Code:
    Columns("J:J").Select    Selection.TextToColumns Destination:=Range("J1"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 1), TrailingMinusNumbers:=True
    ActiveSheet.Range("$A$1:$AM$11576").AutoFilter Field:=10, Criteria1:=8, _
        Operator:=11, Criteria2:=0, SubField:=0

This autofilter is from "last month"
 
Upvote 0
So this code deletes everything that is filtered and visible on the screen, I am looking to do the opposite


Code:
With ActiveSheet.AutoFilter.Range
    .Offset(1).Resize(.Rows.Count - 1).EntireRow.Delete
 
Upvote 0

Forum statistics

Threads
1,216,089
Messages
6,128,760
Members
449,466
Latest member
Peter Juhnke

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