Using Inputboxes to apply date filter TOO SIMPLE FOR U BOFS?

idioteque

Board Regular
Joined
Dec 9, 2003
Messages
50
Hi,

I am using this in my macro as well as input boxes to decipher what DBegin and DEnd values are.

I am just running this as an example and instead of filtering the dates, it filters all dates in that column and don't understand why as the code looks as if it should work fine;

Dim dbegin As Variant, dend As Variant
dbegin = "01/11/2003"
dend = "30/11/2003"


Selection.AutoFilter Field:=12, Criteria1:=">=" & dbegin, Operator:= _
xlAnd, Criteria2:="<=" & dend

Please please, if anyone can help it would be gratefully appreciated.

Regards

Will
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Re: Using Inputboxes to apply date filter

VBA has problems with European style dates. This worked for me:

Code:
Sub Test()
    Dim dbegin As Date, dend As Date
    dbegin = DateValue("01/11/2003")
    dend = DateValue("30/11/2003")
    Selection.AutoFilter Field:=12, Criteria1:=">=" & CLng(dbegin), Operator:= _
    xlAnd, Criteria2:="<=" & CLng(dend)
End Sub
 
Upvote 0
Re: Using Inputboxes to apply date filter TOO SIMPLE FOR U B

Perfect!

Thanks for that Andrew - just what I was looking for.

Will
 
Upvote 0

Forum statistics

Threads
1,225,699
Messages
6,186,523
Members
453,362
Latest member
zermrodrigues

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