• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

pick date automatically [SOLVED]

Sukumar

New Member
Hi,

In following code, I want to change two things,

Code:
Cells.Select
  Selection.AutoFilter
  With ActiveSheet.Range("$A$1:$F$800")
  .AutoFilter Field:=1, Operator:=xlFilterValues, Criteria2:=Array(2, "12/05/2016")
  .AutoFilter Field:=3, Criteria1:="Approved"
  End With

First, I want to change Range to select last low of Col F.

Second, I want to change Criteria to have yesterday's date, i.e. Today()-1

Sukumar
 
Something like below. In VBA Date is equivalent of Today() in formula.

Code:
  With ActiveSheet.Range("A1:F" & Cells(Rows.Count, "F").End(xlUp).Row)
  .AutoFilter Field:=1, Operator:=xlFilterValues, Criteria2:=Date - 1
  .AutoFilter Field:=3, Criteria1:="Approved"
  End With
 
I thank your reply. I am new to this forum and I need suggestions from moderator as how to mark this thread as "answered".
 
Last edited:
Back
Top