+ Reply to Thread
Results 1 to 6 of 6

Filter by Date after

Hybrid View

  1. #1
    Registered User
    Join Date
    11-07-2023
    Location
    Connecticut, USA
    MS-Off Ver
    Microsoft 365 and Office
    Posts
    49

    Filter by Date after

    Hi- I am not sure if this is possible. I looked online on using vba on filtering but none of the topics I read have anything similar of what I need. In the attached example sheet, to filter column D (Hire date) by Filter Date-->After and then I need to select the date that is in column F.

    Once I get those results then the dates that are in the hire column (Column C) needs copy and paste in column F.

    Capture.JPG
    Attached Files Attached Files

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,336

    Re: Filter by Date after

    So...If I understand correctly...
    If the dates in Col D are greater than a specific date then the dates in Col F must become those greater dates of Col D...
    Sub J3v16()
    Dim Dt As Date
    Dt = CDate("20/03/2023")
    With Cells(1).CurrentRegion.Columns(6)
        .Value = Evaluate("=If(Row(" & .Address & "),If(" & .Offset(, -2).Address & "> " & Dt & "," & .Offset(, -2).Address & "," & .Address & "))")
    End With
    End Sub
    Depending on size of data...storing in array and then looping could be faster...
    Sub J3v16()
    Dim Data, Dt As Date, i As Long
    Dt = CDate("20/03/2023")
    With Cells(1).CurrentRegion
        Data = .Value2
        For i = 2 To UBound(Data)
            If Data(i, 4) > Dt Then Data(i, 6) = Data(i, 4)
        Next i
        .Value = Data
    End With
    End Sub
    Last edited by sintek; 04-23-2024 at 02:33 AM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Registered User
    Join Date
    11-07-2023
    Location
    Connecticut, USA
    MS-Off Ver
    Microsoft 365 and Office
    Posts
    49

    Re: Filter by Date after

    @sintek Thank you! specially for the second script because my data is usually up to 20,00 records. Do you know if there is a way to get a box that pops so I can type the date? the date will change every month to something different. Sorry if this is too much to ask. Everything else worked as I wanted.

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,336

    Re: Filter by Date after

    Replace...
    Dt = CDate("20/03/2023")
    With
    Dt = Application.InputBox(FormatDateTime(Date, vbShortDate), , , 1)
    If IsDate(Dt) Then
        Dt = DateValue(Dt)
    Else
        MsgBox "INVALID"
    End If

  5. #5
    Registered User
    Join Date
    11-07-2023
    Location
    Connecticut, USA
    MS-Off Ver
    Microsoft 365 and Office
    Posts
    49

    Re: Filter by Date after

    @Sintek Thank you. You are the best!!

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,336

    Re: Filter by Date after

    Glad to have contributed...Tx for rep +

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 04-24-2020, 04:56 AM
  2. Replies: 1
    Last Post: 04-23-2020, 03:44 PM
  3. Pivot Filter not allowing filter by year, month and date
    By Steve aka Munky in forum Excel Charting & Pivots
    Replies: 8
    Last Post: 02-17-2017, 11:47 AM
  4. Pivot Table: OR condition filter on Multi Date/Sum Filter
    By ddalt10 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 11-09-2013, 12:49 PM
  5. [SOLVED] How to set a 'Date Filter' on a field in the 'Report Filter' section of a Pivot Table?
    By Rhino_dance in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 03-28-2013, 11:01 AM
  6. Filter several pivot tables by one programmed date range filter in Excel 2003
    By olewka in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-08-2011, 11:49 AM
  7. Great Combo Filter/Search form, cant get DATE filter to integrate. HELP
    By fau5tu5 in forum Access Programming / VBA / Macros
    Replies: 4
    Last Post: 05-18-2009, 05:05 PM

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