VBA filter transactions for last quarter data and 1 day before

Knockoutpie

Board Regular
Joined
Sep 10, 2018
Messages
116
Office Version
  1. 365
Platform
  1. Windows
The below snipped captures transaction dates for the last quarter, which is almost perfect, but i need to modify to capture 1 day beyond the last quarter...
Can anyone help me modify that?

Example, Last quarter data is Apr 01 to Jun 30, but I really need Mar 31 to Jun 30.
VBA Code:
    ActiveSheet.Range("$A$1").AutoFilter Field:=2, Criteria1:=11, _
        Operator:=11, Criteria2:=0, SubField:=0
 
Following insights from @Peter_SSs and @Bosquedeguate , please try the following amended code & see if it achieves what you wanted.
VBA Code:
Option Explicit
Sub Knockoutpie_V2()
    Dim ws As Worksheet
    Set ws = Worksheets("Sheet1")   '<~~ *** Change to actual sheet name ***
    Dim StartD As Long, EndD As Long
    
    EndD = DateSerial(Year(Date), (((Month(Date) - 1) \ 3) * 3) + 1, 0)
    StartD = WorksheetFunction.EoMonth(EndD, -3)
    
    With ws.Range("A1").CurrentRegion
        .AutoFilter 2, ">=" & CLng(StartD), 1, "<=" & CLng(EndD)
    End With
End Sub
 
Upvote 0

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Reminder:

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: vba filter dates for all last quarter, and the last day into the quarter before that
There is no need to repeat the link(s) provided above but if you have posted the question at other places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,729
Members
452,939
Latest member
WCrawford

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