Attempting to filter data

imaquila

Board Regular
Joined
Feb 4, 2012
Messages
86
I'm trying to filter records by date but the Value of frmInput.lstDate.Value is equal to 40999. I've tried to format it my lstDate.value as a date using format(frmInput.lstDate.Value,"mmddyy") but that wasn't quite right either. What am I'm missing?


Code:
    If Not .FilterMode Then .Range("A1").AutoFilter
    .Range("A1").AutoFilter , Field:=1, Criteria1:=">=" & "3/31/12", _
        Operator:=xlAnd, Criteria2:="<=" & frmInput.lstDate.Value
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
40999 is a date in Excel (it's 3/31/12). Try this:
Rich (BB code):
If Not .FilterMode Then .Range("A1").AutoFilter
    .Range("A1").AutoFilter , Field:=1, Criteria1:=">=" & DateValue("3/31/12"), _
        Operator:=xlAnd, Criteria2:="<=" & frmInput.lstDate.Value
 
Upvote 0
Hi JoeMo,
Thanks so much for taking the time to post. Your suggestion worked fine for my string "3/31/12" but I'm still getting 40999 for my listbox value (which also suppose to be "3/31/12"). I tried DateValue(lstDate.Value) but that didn't help the problem. Any suggestions for my listbox selection?
 
Upvote 0
Thanks to your help it is now recognizing my dates for filtering.

THANK YOU for taking the time to help a stranger.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
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