How to filter all date cells before or after today in Excel?

In this article, I will talk about how to filter all date cells which before or after today in Excel worksheet.

Filter all date cells before or after today with Filter function

Filter all date cells before or after today with VBA code


Filter all date cells before or after today with Filter function


In fact, the Filter feature in Excel can help you to solve this task as quickly as you can, please do as this:

1. Select the date column that you want to filter, and then click Data > Filter, see screenshot:

doc filter defore today 1

2. Then click the drop down arrow, and then choose Date Filters > Before / After as you need, see screenshot:

doc filter defore today 2

3. In the Custom AutoFilter dialog box, click Date Pickerdoc filter defore today 3 button, and then click Today button in the date picker calendar, see screesnhot:

doc filter defore today 4

4. Then click OK to close the dialog, and all dates before or after today have been filtered out as following screenshot shown:

doc filter defore today 5


Filter all date cells before or after today with VBA code

The following VBA codes also can help you to filter all dates before or after current day in a worksheet. Please do with below steps:

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste one of the following codes in the Module Window.

VBA code: Filter all date cells before today:

Sub FilterDateBeforeToday()
    Dim xLastRow As Long
    Dim xRg As Range
    On Error Resume Next
    Set xRg = Application.InputBox("Please select filtered column:", "KuTools for Excel", Selection.Address, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    ActiveSheet.AutoFilterMode = False
    If xRg.Count = 1 Then Set xRg = xRg.CurrentRegion
    xRg.AutoFilter 1, "<" & CDbl(Date)
    Application.ScreenUpdating = True
End Sub

VBA code: Filter all date cells after today:

Sub FilterDateBeforeToday()
    Dim xLastRow As Long
    Dim xRg As Range
    On Error Resume Next
    Set xRg = Application.InputBox("Please select filtered column:", "KuTools for Excel", Selection.Address, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    ActiveSheet.AutoFilterMode = False
    If xRg.Count = 1 Then Set xRg = xRg.CurrentRegion
    xRg.AutoFilter 1, ">" & CDbl(Date)
    Application.ScreenUpdating = True
End Sub

3. After copying and pasting one of the above codes, then press F5 key to run this code, and a prompt box will pop out to remind you selected the date column that you want to filter, see screenshot:

doc filter defore today 6

4. And then click OK button, all date cells which before or after today will be filtered out immediately.


The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    abhinav.kakku@gmail.com · 1 years ago
    I HAVE DATA in a following format
    12/11/2018 16:10
    12/11/2018 16:10
    12/11/2018 16:10
    12/11/2018 16:10
    12/11/2018 16:10
    12/11/2018 16:10
    12/11/2018 16:10
    12/11/2018 16:10
    12/11/2018 16:10
    12/11/2018 16:10



    and I want to filter it for TODAY - LAST 7 Days Excluding Today , That is if today is 12 Dec I want filter for 12 Dec and December[ 11,10,9,8,7,6,5] .
    How to create custom filter for this in MS Excel