Results 1 to 7 of 7

VBA Code to filter 61 days out from current date

Threaded View

  1. #1
    Registered User
    Join Date
    12-09-2019
    Location
    Orlando, FL
    MS-Off Ver
    2016
    Posts
    3

    VBA Code to filter 61 days out from current date

    Hello All,

    I'm new to the forum (and VBA), and am hoping for some help with an issue. I'm experimenting with creating a macro by recording, and I'm running into a hiccup with one of the filter steps.

    The spreadsheet has 25 columns and I need to filter a handful of them. The last step is looking 61 days ahead, which I usually do by "Date Filters > Before..." and scrolling to the correct date on the calendar. This (as expected) has resulted in the VBA specifically filtering to the resulting date only (2/10/2020). I've tried a few things, none of which work and are probably wrong in a variety of ways haha. I'm not sure if I need to set use Dim sum or something? If so, I'm not really sure how to work that into full code, as most of what I'm finding online is a sub that is only for that single step.

    It might also be worth mentioning that the dates are actually formulas (one of them a basic Cell+/-X and the other a WORKDAY formula). I've tried substituting "today()+61" instead of "2/10/2020" but that doesn't seem to work. Any help would be very appreciated! Thanks.

    Here is the full VBA:



    Sub SortCadenceA10()
    '
    ' SortCadenceA10 Macro
    ' This Macro filters A-10 CDRLs for Cadence, by removing MRTS and any that have been delivered to the customer, and then sorting oldest to newest CDD 61 days out.
    '
    
    '
        ActiveWindow.SmallScroll Down:=-39
        ActiveSheet.Range("$A$2:$U$271").AutoFilter Field:=10, Criteria1:="="
        ActiveWorkbook.Worksheets("CDRLs").AutoFilter.Sort.SortFields.Clear
        ActiveWorkbook.Worksheets("CDRLs").AutoFilter.Sort.SortFields.Add Key:=Range( _
            "I2:I271"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
            xlSortNormal
        With ActiveWorkbook.Worksheets("CDRLs").AutoFilter.Sort
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
        ActiveSheet.Range("$A$2:$U$271").AutoFilter Field:=1, Criteria1:=Array( _
            "A-10 TO-0004 IOS", "A-10 TO-0005 SECB", "A-10 TO-0006 Suite 10"), Operator:= _
            xlFilterValues
        ActiveSheet.Range("$A$2:$U$271").AutoFilter Field:=9, Criteria1:= _
            "<2/10/2020", Operator:=xlAnd
        ActiveWindow.SmallScroll Down:=-36
    End Sub
    Last edited by mjane90; 12-09-2019 at 05:40 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 16
    Last Post: 08-22-2017, 11:20 AM
  2. [SOLVED] Trying to calculate- compares two dates, chooses later date, tells days to current date
    By Vicious00013 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-31-2016, 12:20 PM
  3. [SOLVED] Formula Help: Determine days total from arrival to current date then stop adding days
    By Vicious00013 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-14-2016, 12:45 PM
  4. Replies: 14
    Last Post: 04-06-2015, 09:19 PM
  5. [SOLVED] Need average of days for date values from date to current day that updates current date
    By FinGhost in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-12-2013, 04:41 PM
  6. Replies: 15
    Last Post: 06-26-2012, 07:28 AM
  7. Replies: 2
    Last Post: 02-10-2005, 04:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1