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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
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,226,214
Messages
6,189,669
Members
453,562
Latest member
overmyhead1

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