Filtering by Dates

Pibsandsquibs

New Member
Joined
Aug 18, 2021
Messages
16
Office Version
  1. 365
Platform
  1. Windows
Hello, I have a spreadsheet that has multiple shipments recorded either with a past date or dates in the future (up to 2 months).

Is there a way that I can get excel to filter everything automatically that is arriving in the next 21 days as an example and then it automatically updates this on a daily basis

So based on todays date being 29/08/24 everything that has an arrival date between now and the 19/09/24 appears and then tomorrow shipments that have an arrival date between 30/08/24 and 20/09/24 appears adding the 20/09/24 to the list. Thanks
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Yes, you can use the FILTER function for that since you have 365. Basic syntax:

Excel Formula:
=FILTER(data,(datecol>=TODAY())*(datecol<=TODAY()+21))

where data is the whole data range you want returned and datecol is just the date column.
 
Upvote 0
Try this:

Book1
ABCDE
1
2A28/8/2024B29/8/2024
3B29/8/2024C30/8/2024
4C30/8/2024D31/8/2024
5D31/8/2024
6E1/10/2024
7
Sheet1
Cell Formulas
RangeFormula
D2:E4D2=LET(a,TODAY(),b,a+21,FILTER(A2:B6,(B2:B6>=a)*(B2:B6<=b),""))
Dynamic array formulas.
 
Upvote 0
Yes, you can use the FILTER function for that since you have 365. Basic syntax:

Excel Formula:
=FILTER(data,(datecol>=TODAY())*(datecol<=TODAY()+21))

where data is the whole data range you want returned and datecol is just the date column.
Hi @RoryA many thanks for this, it is amazing, one more question is there a way i can get it to sort the datecol in date order automatically?
 
Upvote 0
Try this:

Book1
ABCDE
1
2A28/8/2024B29/8/2024
3B29/8/2024C30/8/2024
4C30/8/2024D31/8/2024
5D31/8/2024
6E1/10/2024
7
Sheet1
Cell Formulas
RangeFormula
D2:E4D2=LET(a,TODAY(),b,a+21,FILTER(A2:B6,(B2:B6>=a)*(B2:B6<=b),""))
Dynamic array formulas.
thank you @Phuoc this also works, is there a way with this to get the date column to sort in date order automatically?
 
Upvote 0
Yes, you can wrap that in a SORT function and specify the column number:

Excel Formula:
=SORT(FILTER(data,(datecol>=TODAY())*(datecol<=TODAY()+21)),datecol_number)
 
Upvote 0
Yes, you can wrap that in a SORT function and specify the column number:

Excel Formula:
=SORT(FILTER(data,(datecol>=TODAY())*(datecol<=TODAY()+21)),datecol_number)
Thanks @RoryA I might be missing something. For the datecol_number that you have added at the end of the formula. Is that the original datecol (as in where it is pulling the data from in the first formula) or where it is in the filter.

My results are not filtering in numerical order at the moment.
 
Upvote 0
Are you including the date column in the output of the filter? If so, it's the position of the date column in the results. If not, we'll need to redo the formula to sort the data first, then filter.
 
Upvote 0
Are you including the date column in the output of the filter? If so, it's the position of the date column in the results. If not, we'll need to redo the formula to sort the data first, then filter.
@RoryA yes the date column is included. I have just entered 24 as this is the date column is the 24th column and excel didn't like it and wanted to multiply the formula by 24 which there returned errors
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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