Solved

Autofilter equal to or less than today?

Posted on 2014-02-25
6
408 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

777 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