Filter table by date in another cell

afc171

Board Regular
Joined
Jan 14, 2017
Messages
145
Office Version
  1. 2013
Platform
  1. Windows
Hi all,

how would I filter the table bye column C if I enter a date in L1?

1.PNG


Thank you
 

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.
Put in the following code in your sheet events.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Address = "$L$1" Then
    If Target.Count > 1 Then Exit Sub
    If IsDate(Range("L1").Value) Then
      ActiveSheet.Range("$A$1:$I$1").AutoFilter
      Range("A1:I1").AutoFilter 3, , xlFilterValues, Array(2, Format(Range("L1").Value, "mm/dd/yyyy"))
      Range("L1").Select
    End If
  End If
End Sub

Note Sheet Event:
Right click the tab of the sheet you want this to work, select view code and paste the code into the window that opens up.
 
Upvote 0
Solution

Forum statistics

Threads
1,221,577
Messages
6,160,610
Members
451,657
Latest member
Ang24

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