filter dates formula using advance criteria.

wayneseymour

New Member
Joined
Dec 7, 2016
Messages
7
I have an advanced filter that runs on my Excel VBA application which is suppose to filter dates in the data base, I created the advance filter on the worksheet and it works fine except for when it comes to filtering dates this is the formula I'm using:


=IF(C5="",">1","<=" &C5) start date


=IF(C5="","<60000","<" &C5) end date


I tried removing the Quotes from the <60000 but received a error.
the filter will not filter the dates requested.

For example I ask to filter date between 9/20/2018 and 9/30/2018 I get results outside those dates as well as the dates requested.
another example ,If I ask for dates of say 5/1/2016 and 5/30/2016 I get dates from 4/1/2016 as well. I I ask for all records with the date of 9/29/2018 I get nothing.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Are the dates real dates or text looking like dates ? (in the latter case they are left aligned in the cells if no custom alignment is applied)
 
Upvote 0
The formatting is not what matters, it's the underlying data
Just to be sure use the TYPE function on one of the dates. If it does not return 1, they are not real dates
 
Upvote 0
I'm sorry, I have no knowledge of VBA, but I don't understand what =IF(C5="",">1","<=" &C5) start date is supposed to do
 
Upvote 0
I'm sorry, I have no knowledge of VBA, but I don't understand what =IF(C5="",">1","<=" &C5) start date is supposed to do


In the Advance Criteria filter It will allow you to filter your advance filtered data between dates .
=IF(C5="",">1","<=" &C5) and =IF(B5="",">1","<=" &B5) is your End date and start dates respectfully.
I worked out a small portion of the problem I was having, but the main thing that still bugs me is that the advance filter will not filter the dates if the End date and Start dates are the same,In addition to get a correct scope of the dates you have to enter a day ahead in the start date and a day after in the end date in order to get the dates of data you are filtering for. Example. if the dates you want are say 4/28/2018 you have to enter 4/27/2018 for your start date and 4/29/2018 for your end date. if not and you enter 4/28/2018 as your start and end dates you get no results. If you are filtering for dates at the end of a month your end date has to be the following month ie. you want records at the end of April 4/30/2018, you have to place 4/29/2018 as your start date and 5/1/2018 as your end date., then you will get all records for the 30th. But if you use the 30th as the start and end date you get no results. hope you follow what i'm saying.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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