+ Reply to Thread
Results 1 to 16 of 16

Vlookup result only when an id matches AND dates are within a range

  1. #1
    Registered User
    Join Date
    08-03-2012
    Location
    Cork Ireland
    MS-Off Ver
    Excel 2007
    Posts
    66

    Vlookup result only when an id matches AND dates are within a range

    Hi All,
    been a while!!!

    i know i should be posting a book but this data is sensitive and i'd find it hard to create a demo version so i'll do my best to explain.


    Column A on book one contains and identifier, Column C on the results book has the same IDENTIFIER,

    then each identifier on book one has an in date and an out date

    on the results sheet there is a service date,

    i am trying to do is, vlookup up a result but only when the ID numbers match and the service date is between in date and out date.

    my attempt.

    =AND(VLOOKUP(C8,[Book1]Sheet1!$A:$H,8,0),B8>=[Book1]Sheet1!$C:$C,B8<=[Book1]Sheet1!$D:$D)

    any questions blast away!

    cheers
    D

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Vlookup result only when an id matches AND dates are within a range

    Are the dates in Book one Sorted in any way?
    Are those date ranges all inclusive? i.e. say D2 is 7/31, then C3 is 8/1 (no gaps between end dates in D and the next begin dates in C)
    Last edited by Jonmo1; 07-06-2017 at 08:32 AM.

  3. #3
    Forum Expert avk's Avatar
    Join Date
    07-12-2007
    Location
    India
    MS-Off Ver
    Microsoft Office 2013
    Posts
    3,223

    Re: Vlookup result only when an id matches AND dates are within a range

    If you attach sample file, then clear idea. (mentioned expected result in required cell)


    atul


    If my answer (or that of other members) has helped you, please say "Thanks" by clicking the Add Reputation button at the foot of one of their posts.

    Also: if your problem is solved, please take the time to mark your thread as SOLVED by going to the top of your first post, selecting "Thread Tools" and then "Mark thread as solved".

  4. #4
    Registered User
    Join Date
    08-03-2012
    Location
    Cork Ireland
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: Vlookup result only when an id matches AND dates are within a range

    Hi Jonmo,

    thanks for taking the time to reply,

    a caveat i failed to mention, the ID is unique, but it may appear several times with different dates, a different result may
    be next to each date and ID, i.e.

    ID Dates Results
    1234 01/01/16 - 3/01/16 Result:engine overhaul
    2356 3/01/16 3/01/16 Result: Tire Change

    my new attempt, but i fear the vlookup isnt throwing back results based on the ID and its Active date

    =IF(AND(VLOOKUP(D2,[Book1.xlsx]Sheet1!$A:$A,1,FALSE),LOOKUP(B2,[Book1.xlsx]Sheet1!$C$2:$D$2147)),VLOOKUP(D2,[Book1.xlsx]Sheet1!$A:$H,8,FALSE))

  5. #5
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Vlookup result only when an id matches AND dates are within a range

    Does this work? You may need to open the Book1 workbook for this to work.

    =VLOOKUP(C8,IF(AND(B8>=[Book1]Sheet1!$C1:$C100000,B8<=[Book1]Sheet1!$D1:$D100000),[Book1]Sheet1!$A1:$H100000),8,0)
    Array formula, use Ctrl-Shift-Enter
    Last edited by Special-K; 07-06-2017 at 09:04 AM.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Vlookup result only when an id matches AND dates are within a range

    You didn't really answer my questions.

    Also, what type of data is in column H that the vlookup should be returing?
    Is it TEXT or Number ?

  7. #7
    Registered User
    Join Date
    08-03-2012
    Location
    Cork Ireland
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: Vlookup result only when an id matches AND dates are within a range

    my apologies to all for being unclear, and for not answering questions, due to the sensitive nature of the data, i have made up a dummy file.

    in sheet account data, you will see c2 is an expected result.

    there is a second sheet called service bay data, this is the data i need to compare my data against.

    in english, vlookup a Customer number when the Service date on the account data sheet is between "arrived in bay" and "left bay dates"
    on the service bay sheet, then return what service they got.

    i hope that makes sense, and apologies for wasting anyones time!

    (uploading file please wait)

  8. #8
    Registered User
    Join Date
    08-03-2012
    Location
    Cork Ireland
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: Vlookup result only when an id matches AND dates are within a range

    I'm clearly an idiot and cant see where to upload files anymore?
    any help lol

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Vlookup result only when an id matches AND dates are within a range

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  10. #10
    Registered User
    Join Date
    08-03-2012
    Location
    Cork Ireland
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: Vlookup result only when an id matches AND dates are within a range

    ***********************see below for attachment
    Last edited by unreal_event_horizon; 07-07-2017 at 09:08 AM.

  11. #11
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Vlookup result only when an id matches AND dates are within a range

    Im getting invalid attachment.

  12. #12
    Registered User
    Join Date
    08-03-2012
    Location
    Cork Ireland
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: Vlookup result only when an id matches AND dates are within a range

    Hopefully this attachment has worked, I had to remake the excel file, had a corruption issue yesterday.


    and a side note to all , thanks for your patience
    Attached Files Attached Files

  13. #13
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Vlookup result only when an id matches AND dates are within a range

    Try

    =INDEX('Service Bay Data'!$E$2:$E$8,MATCH(1,INDEX(('Service Bay Data'!$B$2:$B$8=A2)*('Service Bay Data'!$C$2:$C$8<=B2)*('Service Bay Data'!$D$2:$D$8>=B2),0),0))

  14. #14
    Registered User
    Join Date
    08-03-2012
    Location
    Cork Ireland
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: Vlookup result only when an id matches AND dates are within a range

    incredible, exactly what i was after Jonmo1! cheers for the patience!

    i broke it down to use it else where and have learned from it!

    thanks to all! marking Solved

  15. #15
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Vlookup result only when an id matches AND dates are within a range

    To mark the thread as solved, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  16. #16
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Vlookup result only when an id matches AND dates are within a range

    You're welcome.

+ 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. [SOLVED] Conditional Format Calendar if Date Matches Range of Dates in Other Cells
    By blackburnsexcel in forum Excel General
    Replies: 7
    Last Post: 06-23-2016, 01:18 PM
  2. Find word within text that matches range and Vlookup the result
    By snakeCZ in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-19-2015, 04:28 AM
  3. [SOLVED] VBA Command button enabled if current date matches with range of dates
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-15-2014, 01:01 PM
  4. Display Cell within VLookup range that excel thinks matches the VLookup Value
    By headachexcelperson in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-04-2013, 04:56 PM
  5. [SOLVED] A cell of Date matches with a range of DATES
    By soundworks999 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-09-2013, 09:57 PM
  6. Replies: 8
    Last Post: 04-18-2012, 09:49 AM
  7. VLOOKUP - Return sum of all matches in Range?
    By Wiggz in forum Excel General
    Replies: 3
    Last Post: 01-25-2007, 06:42 AM

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