vba AutoFilter on date

Jockster

Board Regular
Joined
Jan 16, 2009
Messages
88
I am having trouble filtering a column on dates.
I have read much in forums about there being an immediate issue with this unless you are using the American region system format which I'm not.
I have however used a helper comumn to filter on which stores the date serial number rather than a date.
I find that the code will only filter and display the data of the last row if the date (serial) is greater than today's date (serial). If I change the date in a row further up to fit the criteria, that row is ignored.
code snippet below.
Code:
Sub Pending()
Dim SDate As Date
 
If IsDate(Range("A1")) Then 'establish if a date is in A1
    SDate = Range("A1")
    SDate = DateSerial(Year(dDate), Month(dDate), Day(dDate))
End If
Dim LDate As Long
 
Set My_Range = ActiveSheet.Range("A3:Q" & LastRow)
My_Range.select
LDate = SDate
 
  'Set the filter fields and the filter criteria
       My_Range.AutoFilter Field:=11, Criteria1:="P" 'shows only ticked cells
        My_Range.AutoFilter Field:=17, Criteria1:=">" & LDate 
 
 End sub
If anyone can point me in the right direction, I'd appreciate it.
I hate dates.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

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