How to Filter Date Range in Excel (5 Easy Methods)

We’ll consider the sample dataset that contains the sales quantity of some electronic products in a shop in January, February, and March. We’ll filter the sales based on a date range.

how to filter date range in excel


Method 1 – Using the Excel Filter Command to Filter a Date Range

Case 1.1 – Filtering a Date Range by Selection

We’ll get the sales quantity in the months of January and March.

Steps:

  • Select cell B4.
  • Go to Home, then to Sort & Filter, and select Filter.

  • Click on the drop-down icon in cell B4.

how to filter date range in excel

  • Unmark January and March and click OK.

  • You will see the information about the sales in February.

how to filter date range in excel

  • Select the range B10:D12 and right-click on any of the selected cells.
  • Click on Delete Row.

  • A warning message will appear. Click OK.

how to filter date range in excel using filter command

  • This operation will remove all the information of the product sales in February.
  • Select Filter from Sort & Filter ribbon again.

  • You will see the information about the sales in January and March only.

how to filter date range in excel


Case 1.2 – Filtering a Date Range Using Date Filters

Steps:

  • Select any cells between B4 and D4.
  • Go to Home then to Sort & Filter and select Filter.

  • Click on the drop-down icon in cell B4.

how to filter date range in excel

  • Select Custom Filter from Date Filters.

  • Set the Date as ‘is before 01-02-22 Or is after 07-02-22’ (see the figure below)

how to filter date range in excel

  • Click OK and you will see the sales information in the months of January and March.


Method 2 – Filtering Dates by Using the FILTER Function

We’ll fetch the sales in February.

Steps:

  • Make a new chart like the following figure with the same column headers as the original.

how to filter date range in excel using filter function

  • Make sure that the cell format of column F is set to Date.

  • Use the following formula in cell F5.
=FILTER(B5:D14,MONTH(B5:B14)=2,"No data")

how to filter date range in excel

  • Press Enter and you will see all the information about product sales in February.


Method 3 – Utilizing a Pivot Table to Filter the Range of Dates

We’ll get the total sales in January.

Steps:

  • Select the range B4:D12.
  • Go to Insert and select PivotTable.

how to filter date range in excel using pivot table

  • A dialog box will pop up. Click OK.

  • You will see PivotTable Fields on the right side in a new Excel Sheet. It has all Fields from the Column Headings of your dataset. There are four areas: Filters, Columns, Rows, and Values. You can drag any Field on these Areas.

how to filter date range in excel using pivot table

  • Click on Date in the PivotTable Field. You will see another field, Month.

  • Unmark Date and mark Products and Sales Qty. from Fields.
  • Drag the Months field from the area of Rows to Filters (Shown in the following image).

how to filter date range in excel using pivot table

  • This will show every Sale and Product of the dataset in a Pivot Table.

  • To see the Sales in January, click on the arrow of the marked area in the following picture, and then select Jan.
  • Click OK.

how to filter date range in excel using pivot table

  • You can also see the total sales of January.


Method 4 – Applying VBA to Filter a Date Range

We’ll get the sales in February and March.

Steps:

  • Open Visual Basic from the Developer Tab.

how to filter date range in excel using VBA

  • Open Insert and select Module.

  • Use the following code in the VBA Module.
Public Sub DateRangeFilter()
    Dim StartDate As Long, EndDate As Long
    StartDate = Range("B10").Value
    EndDate = Range("B14").Value
    Range("B4:B14").AutoFilter field:=1, _
        Criteria1:=">=" & StartDate, _
        Operator:=xlAnd, _
        Criteria2:="<=" & EndDate
End Sub

how to filter date range in excel using VBA

As we want to know about the sales in the months of February and March, we set the first date of February as our start date (cell B10) and the last date of March as our end date (cell B14) using the Range and Value method. Then we used the AutoFilter method to Filter this date range from B4:B14 by setting criteria for the start date and end date.

  • Run the Macro from the Excel sheet.

how to filter date range in excel using VBA

  • You will only see the dates of February and March.

how to filter date range in excel using VBA

Read More: Excel VBA: Filter Date Range Based on Cell Value


Method 5 – Using Excel AND and TODAY Functions to Filter a Date Range

We want to know the sales history with dates between 60 and 80 days ago from today.

Steps:

  • Make a new column and name it as you wish. We named it Filtered Date.
  • Use the following formula in cell E5.
=AND(TODAY()-B5>=60,TODAY()-B5<=80)

  • Hit the Enter key and you will see the output in cell E5.

how to filter date range in excel

  • Use the Fill Handle to AutoFill lower cells.

  • Select cell E5 and go to Sort & Filter and select Filter.

how to filter date range in excel

  • Click on the arrow in column E, unmark FALSE, and then click OK (shown in the following figure).

  • You will see the sales history among your desired range of dates.

how to filter date range in excel

Read More: [Fixed!] Excel Date Filter Is Not Grouping by Month


Practice Section

We’ve provided a practice section in the download file so you can test these methods.


Download the Practice Workbook


Knowledge Hub


<< Go Back to Filter in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Meraz Al Nahian
Meraz Al Nahian

Md. Meraz Al Nahian has worked with the ExcelDemy project for over 1.5 years. He wrote 140+ articles for ExcelDemy. He also solved a lot of user problems and worked on dashboards. He is interested in data analysis, advanced Excel, statistics, and dashboards. He also likes to explore various Excel and VBA applications. He completed his graduation in Electrical & Electronic Engineering from Bangladesh University of Engineering & Technology (BUET). He enjoys exploring Excel-related features to gain efficiency... Read Full Bio

2 Comments
  1. That was wonderful! I didn’t expect anybody to be able to help, but your method 5 was perfect for my needs. Thank you!

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo