Filtering by "yesterday's" date

rharri1972

Board Regular
Joined
Nov 12, 2021
Messages
132
Office Version
  1. 2019
Platform
  1. Windows
Hello! I have a an open order report that I need to filter by "yesterday's" date or today's date (-) 1. This will be filtered in the "order date" column which is always column 6.

Obviously being an open orders report, this column has several dates in it and I need to specifically filter JUST the dates of orders that were processed the previous day.

Can anyone help me with VBA on this please?

Thanks in advance.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
do you specifically need a VBA solution
=IFERROR(IF(INDEX($A$2:$A$26,SMALL(IF($B$2:$B$26=TODAY()-1,ROW($A$2:$A$26)),ROW(1:1))-1,1)=0,””,INDEX($A$2:$A$26,SMALL(IF($B$2:$B$26=TODAY()-1,ROW($A$2:$A$26)),ROW(1:1))-1,1)),"")

Extract list before today.xlsx
ABCDEF
1Vehicle No.Expire DateLIST
26751/31/19675a
3790a10/28/19790b
4675a2/14/23675b
5790b2/14/23 
6675b2/14/23 
7790c2/15/23 
8675c2/15/23 
9675d2/15/23 
10675e2/15/23 
11675f2/15/23 
1212a2/15/23 
1345672/15/23 
1412142/15/23 
Sheet1
Cell Formulas
RangeFormula
B4:B6B4=TODAY()-1
B7:B14B7=TODAY()
F2:F14F2=IFERROR(IF(INDEX($A$2:$A$26,SMALL(IF($B$2:$B$26=TODAY()-1,ROW($A$2:$A$26)),ROW(1:1))-1,1)=0,””,INDEX($A$2:$A$26,SMALL(IF($B$2:$B$26=TODAY()-1,ROW($A$2:$A$26)),ROW(1:1))-1,1)),"")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A1:B14Expression=$B1=TODAY()-1textYES
 
Upvote 0
I think I found a solution before. I will see if i can find and repost.
 
Upvote 0
Try the following:
VBA Code:
Option Explicit
Sub Yesterday()
    Dim ws As Worksheet
    Set ws = Worksheets("Sheet1")   '<~~ *** Change to actual sheet name ***
    
    With ws.Range("A1").CurrentRegion
        .AutoFilter 6, 2, 11
    End With
End Sub

Before (it's the 17th May here now)
Book1
ABCDEF
1HDR1HDR2HDR3HDR4HDR5Order Date
2datadatadatadatadata15/05/2023
3datadatadatadatadata15/05/2023
4datadatadatadatadata15/05/2023
5datadatadatadatadata16/05/2023
6datadatadatadatadata16/05/2023
7datadatadatadatadata16/05/2023
8datadatadatadatadata17/05/2023
9datadatadatadatadata18/05/2023
10datadatadatadatadata19/05/2023
11datadatadatadatadata20/05/2023
Sheet1


After:
Book1
ABCDEF
1HDR1HDR2HDR3HDR4HDR5Order Date
5datadatadatadatadata16/05/2023
6datadatadatadatadata16/05/2023
7datadatadatadatadata16/05/2023
12
Sheet1
 
Upvote 0

Forum statistics

Threads
1,214,926
Messages
6,122,306
Members
449,079
Latest member
juggernaut24

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