+ Reply to Thread
Results 1 to 6 of 6

find data inbetween dates

  1. #1
    Forum Contributor
    Join Date
    03-04-2013
    Location
    Europe
    MS-Off Ver
    Office 365 ProPlus
    Posts
    147

    find data inbetween dates

    I'm trying to extract certain data out of an array based on a "start date" and an "end date", what function in vb can i use to locate my first date in the array?

    I have made an example workbook where i have 1 column of dates, 4 columns of values, a start date and an end date. I would like to write some code to extract the data from the values between these dates. I was thinking of doing some sort of do-while loop but i can't get it started because i dont know how to locate/match/find my start date in the array.
    Attached Files Attached Files

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: find data inbetween dates

    Hi vizzkid. Try the following code.
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    03-04-2013
    Location
    Europe
    MS-Off Ver
    Office 365 ProPlus
    Posts
    147

    Re: find data inbetween dates

    Thanks a lot Mumps1! I'll be sure to try this.

    But isn't there a easier way? I thought there might be a vlookup-like function, so that i could just match the start date with a date in the array?

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: find data inbetween dates

    Hi vizzkid. There may be another way using formulas but they are not my strong suit. The advantage of using the macro is that it automatically adjusts for the number of dates (rows) you are matching. You could easily insert a button on your sheet and assign the macro to it to make it easy to run.

  5. #5
    Forum Contributor
    Join Date
    03-04-2013
    Location
    Europe
    MS-Off Ver
    Office 365 ProPlus
    Posts
    147

    Re: find data inbetween dates

    Yeah that's what i'm doing, it's part of bigger scheme.. Just have a bit of trouble understanding the code. I'll do some experimenting and I'm sure I'll get it. Thanks for your help!

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: find data inbetween dates

    Glad to help. The code uses two loops. The first loop finds the first empty cell in column A. The second loop uses the row number of the empty cell to define the bottom of the search range (y-1). Then the loop searches for the dates based on your criteria and copies them to the first blank row at the bottom of your sheet. I hope that helps.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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