Solved

Autofilter equal to or less than today?

Posted on 2014-02-25
6
401 Views
Last Modified: 2014-02-26
How do I write an autofilter that says =< today?

   ActiveSheet.RangeUsed.AutoFilter Field:=37, Operator:= _
    xlFilterValues, Criteria2:=Array(0, DateValue(Now) - 1)

Open in new window

0
Comment
Question by:RWayneH
  • 3
  • 2
6 Comments
 
LVL 22

Expert Comment

by:Flyster
ID: 39887670
You can try:
   ActiveSheet.RangeUsed.AutoFilter Field:=37, Operator:= _
    xlFilterValues, Criteria2:="<=" & Array(0, DateValue(Now) ) 

Open in new window

Flyster
0
 

Author Comment

by:RWayneH
ID: 39887691
For some reason this is failing.  I forgot too that I need to take out the blanks and the #N/A's.  All I need to see are the cells that have dates and are =< today.
0
 
LVL 16

Expert Comment

by:Jerry Paladino
ID: 39887695
ActiveSheet.RangeUsed.AutoFilter Field:=37, Operator:= _
    xlFilterValues, Criteria2:="<=" & Format(Date, "m/d/yyyy")

This should eliminate blanks and #NA
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:RWayneH
ID: 39887712
Here is the sheet that I am trying to run the autofilter on and here is the code that is failing.

' Macro13 Macro
'Sheets("CDPSRECRPT-Yesterday").Select
    Rows("1:1").Select
    Selection.AutoFilter  'filter on
   
'    ActiveSheet.RangeUsed.AutoFilter Field:=37, Operator:= _
'    xlFilterValues, Criteria2:="<=" & Array(0, DateValue(Now))
    
    ActiveSheet.RangeUsed.AutoFilter Field:=37, Operator:= _
    xlFilterValues, Criteria2:="<=" & Format(Date, "m/d/yyyy")

    RowCnt2 = ActiveSheet.UsedRange.Columns(1).SpecialCells(xlVisible).Count
    Sheets("MOT-MeasureData").Select
    Range("C2").Select 'put the number complete in the previous day
    Range("C3") = RowCnt2  'places the number in MOT-MeasureData

'

End Sub

Open in new window

CDPS.xlsx
0
 
LVL 16

Accepted Solution

by:
Jerry Paladino earned 500 total points
ID: 39887735
I believe it was failing because you had "RangeUsed" instead of "UsedRange".  
     ActiveSheet.UsedRange.AutoFilter Field:=37, _
    Criteria1:="<=" & Format(Date, "m/d/yyyy"), Operator:=xlFilterValues

Open in new window

Edited - Sorry - I copied the wrong one
0
 

Author Closing Comment

by:RWayneH
ID: 39888839
Thanks for the help. -R-
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem to open Excel file 15 45
Excel : show empty cell if zero 7 22
TT Copy Formula 3 16
Macro Filter fix 3 13
As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now