filter out rows on a sheet based on user selected date.

steve400243

Active Member
Joined
Sep 15, 2016
Messages
429
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hello, On the attached workbook, when a user selects a date in cell B1, I need any other rows that does not have that Date in Column E to be filtered out. In the Example, the Row 4, and 5 would be hidden after entering 4/27 in cell B1. Hope this explains what I am Looking for. Thank you.

Herban Cowboy Test.xlsx
ABCDEFGHIJKN
1Ship DateWed.Apr.27.2022cc:426cc:025cc:426cc:430cc:473
2$5.25$12.50$1.05$0.25$22.00
3Order NumberPurchase OrderDestinationOrder DateShip DateCarrierOrder ChargeBOL Fee Carton Out Charge FedEx LabelsFedEx Pallet Weekly Charges
42970774416463047UNFI - ROCKLINApr-20Apr-20UNFI11121$ 41.30
52970772456808572UNFI - AURORAApr-20Apr-20UNFI11221$ 42.35
62970773476811839UNFI - LANCASTERApr-20Apr-27UNFI11621$ 46.55
72970776466789884UNFI - RIDGEFIELDApr-20Apr-27UNFI11121$ 41.30
82970775446554404UNFI - RIVERSIDEApr-20Apr-27UNFI111021$ 50.75
92970767107210THRESHOLD ENTApr-20Apr-27FEDEX FRT11191$ 59.70
10Total$ 281.95
Data
Cell Formulas
RangeFormula
N4:N9N4=[Order Charge]*$G$2+[BOL Fee]*$H$2+[Carton Out Charge]*$I$2+[FedEx Labels]*$J$2+[FedEx Pallet]*$K$2
N10N10=SUBTOTAL(109,[Weekly Charges])
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A4:A9Cell ValueduplicatestextNO
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Try the following worksheet change code in the worksheet code area of the Data sheet.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Range("B1"), Target) Is Nothing Then
    Application.EnableEvents = False
        With Range("A3:E3")
            .AutoFilter 5, Format(Range("B1").Value, "mmm-dd")
        End With
    End If
    Application.EnableEvents = True
End Sub
 
Upvote 0
Solution
Try the following worksheet change code in the worksheet code area of the Data sheet.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Range("B1"), Target) Is Nothing Then
    Application.EnableEvents = False
        With Range("A3:E3")
            .AutoFilter 5, Format(Range("B1").Value, "mmm-dd")
        End With
    End If
    Application.EnableEvents = True
End Sub
Kevin9999, Thanks for your code, But I cannot get this to run after pasting the code in the worksheet?
 
Upvote 0
Kevin9999, Thanks for your code, But I cannot get this to run after pasting the code in the worksheet?
Did you right-click on the sheet tab name, select 'view code', and paste the code in the windows that appeared? If so, the code should run whenever the value changes in cell B1.
 
Upvote 0
Did you right-click on the sheet tab name, select 'view code', and paste the code in the windows that appeared? If so, the code should run whenever the value changes in cell B1.
Ahhhh, need more coffee, I copied and pasted it after hitting alt F11. Works as needed now, thank you!
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

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