Excel VBA Code Date Filter between two dates

bhaskar_bkp

New Member
Joined
Apr 27, 2010
Messages
3
:confused:
I want to filter data between "15 apr 2010" and "26 apr 2010" . All Dates are stored in column B. The below code is generated by excel macro recorder but despite having dates between the specified range nothing is showing when I run the macro. Dates are stored in "dd/mm/yyyy" format
Please help me.
Thanx

ActiveSheet.Range("$B$5:$O$289").AutoFilter Field:=2, Criteria1:= _
">=15/04/2010", Operator:=xlAnd, Criteria2:="<=26/04/2010"
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hi,

Change date format in code from dd/mm/yyyy to mm/dd/yyyy
Code:
ActiveSheet.Range("$B$5:$O$289").AutoFilter Field:=2, Criteria1:= _
        ">=4/15/2010", Operator:=xlAnd, Criteria2:="<=4/26/2010"
 
Upvote 0
Thank u very much Sahak for ur help. I have searched for the solution for a long time & u solved it so easily.

I have another question. I gather the start date & end date using a popup calender. I use the following code.

Calendar.Show
startDate = Selection

Now "15/4/2010" is stored in "startDate" . How to change the date format of "startDate" from "dd/mm/yyyy" to "mm/dd/yyyy"?

Thanx in advance.
 
Upvote 0
:biggrin:It worked. Thanx again Sahak for ur reply. Thanx to the Person Who Knows Excel All The Way.

I have solved the above question. I changed the code to .....

startDate = Format(startDate, "mm/dd/yyyy")
 
Last edited:
Upvote 0
Hi there, is there any way to do the above:
. In Excel 2010?
. With a dialogue box to ask for start & end dates to search column B of the 'Data' sheet)
. And for found rows to be copied across to a sheet called 'Reports'?
 
Upvote 0
hi there , i need a program to get data between the dates 7/5/2015 and 7/10/2015 in my excel document. can u help me with the code figure out a solution.
 
Upvote 0
hi there , i need a program to get data between the dates 7/5/2015 and 7/10/2015 in my excel document. can u help me with the code figure out a solution.

Probably late, but here it is


ActiveSheet.Range(YOUR RANGE).AutoFilter Field:=3, Criteria1:=">=7/05/2015", Operator:=xlAnd, Criteria2:="<=7/10/2015"
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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