PDA

View Full Version : Help with filter by date



Programs1234
08-14-2017, 12:39 PM
I am trying to filter for dates before today. However, my code below is just simply not working. It runs but it does not seem to be filtering. Anybody know whats wrong with the code below? Thanks!

Sheets(1).Range("A1:AC1").AutoFilter Field:=11, Criteria1:="<" & CLng(Date)

YasserKhalil
08-14-2017, 12:48 PM
May be those lines help you (Not Testes)

Dim myDate As Date
myDate = DateSerial(Year(myDate), Month(myDate), Day(myDate))
Sheets(1).Range("A1:AC1").AutoFilter Field:=11, Criteria1:="<" & myDate

p45cal
08-14-2017, 01:17 PM
No balls… quite so.

Programs1234
08-14-2017, 01:32 PM
I tried using your code above. It kind of spits out the same results. I think it sort of skips over that line without doing anything.

Programs1234
08-14-2017, 01:41 PM
I double checked and as it turns out your code actually works just fine. I just made a small organization error. Thanks!

YasserKhalil
08-14-2017, 02:03 PM
You're welcome. Glad I can offer some help