+ Reply to Thread
Results 1 to 4 of 4

VBA - First and last row between dates

  1. #1
    Registered User
    Join Date
    11-15-2012
    Location
    USA
    MS-Off Ver
    Office 2013
    Posts
    2

    VBA - First and last row between dates

    I have a data set similar to the one below. In VBA, how do I find the first row on or after "StartDate" and the last row on or before "EndDate. In this example, on or after 01/10/2022 and on or before 01/14/2022.

    Date Product Qty Sales
    1/3/2022 Prod3 16 $70.72
    1/3/2022 Prod1 24 $106.08
    1/3/2022 Prod2 19 $83.98
    1/3/2022 Prod2 14 $61.88
    1/4/2022 Prod2 18 $79.56
    1/4/2022 Prod3 23 $101.66
    1/4/2022 Prod1 16 $70.72
    1/10/2022 Prod2 18 $79.56
    1/10/2022 Prod3 23 $101.66
    1/10/2022 Prod2 23 $101.66
    1/10/2022 Prod3 10 $44.20
    1/11/2022 Prod3 7 $30.94
    1/12/2022 Prod1 20 $88.40
    1/12/2022 Prod1 14 $62.22
    1/13/2022 Prod2 14 $59.99
    1/13/2022 Prod3 13 $57.75
    1/15/2022 Prod3 12 $51.05
    1/15/2022 Prod2 11 $48.81
    1/16/2022 Prod3 11 $46.58
    1/16/2022 Prod3 10 $44.35
    1/17/2022 Prod1 10 $42.11

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,936

    Re: VBA - First and last row between dates

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    11-15-2012
    Location
    USA
    MS-Off Ver
    Office 2013
    Posts
    2

    Re: VBA - First and last row between dates

    Bernie, this is great. I just solved it myself, but this is a much better way. Thank you

  4. #4
    Valued Forum Contributor
    Join Date
    08-07-2014
    Location
    Quito, Ecuador
    MS-Off Ver
    Excel 2016 & 365, Windows 10
    Posts
    511

    Re: VBA - First and last row between dates

    If your data table starts at A1, you place the start date in G3 and the end date in G4;
    the following code will do what you need.

    Please Login or Register  to view this content.
    Barriers are there for those who don't want to dream

+ 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: 8
    Last Post: 07-20-2018, 11:52 AM
  2. Populating list of dates from another sheet with Start Dates and End Dates
    By Jesshloly in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-05-2015, 04:07 AM
  3. Check dates in range either same dates or different dates by formula
    By breadwinner in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-12-2013, 07:42 AM
  4. Replies: 6
    Last Post: 03-11-2013, 06:11 PM
  5. [SOLVED] Array of dates when tested shows no dates ......but there are dates
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-29-2012, 12:45 PM
  6. [SOLVED] Highlight Group of Dates if Dates Match List of other Dates
    By martinpgibson in forum Excel General
    Replies: 5
    Last Post: 10-24-2012, 08:14 PM
  7. [SOLVED] Auto filling dates based on previously entered dates and averaging numbers if dates equal
    By grambograham in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-11-2012, 03:21 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