+ Reply to Thread
Results 1 to 23 of 23

Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

  1. #1
    Forum Contributor
    Join Date
    02-09-2016
    Location
    West Midlands
    MS-Off Ver
    2016
    Posts
    224

    Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    Hi again guys!

    Sorry for frequent posts, im nearly sorted apart from a LOOKUP im trying to perform.

    This is what im trying to achieve;

    I have x2 Worksheets ("FORMULAS" & "DATA")

    Im after a formula to look for the 'Time' from Cell E2 in Worksheet 'FORMULAS' (and also use it in Cell E3) and find a match in a Range Defined as "UKDATA" in Worksheet 'DATA'.

    This is the part i cant figure out...

    Once it finds a match;
    If the 5th Row down from the Matched 'Time' has the first character of "J" return the value of the row above (ie, the 4th row down from the Time Match).
    If the 5th Row down from the Matched 'Time' does not have a "J" as the first character, then return the 5th row down.

    I have Uploaded my simplified Spreadsheet and added Notes to highlight the result and where to find all relevant Lookups/Match's and Data.

    Thanks for taking your time, any help is greatly appreciated!
    Attached Files Attached Files

  2. #2
    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,647

    Re: Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    First of all, do you realise that there are no time matches in your sample file? 03:45 is not the same as 15:35 - they are 12 hours apart. Are they both meant to be PM?
    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.

  3. #3
    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,647

    Re: Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    The other problem is that there are not even numbers of AAAAAAAAAAA rows between times and J rows - there are four in the first and 3 in the second, so your required formula will not work for the second time.

  4. #4
    Forum Contributor
    Join Date
    02-09-2016
    Location
    West Midlands
    MS-Off Ver
    2016
    Posts
    224

    Re: Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    Hi Ali!

    This is a problem ive been having as i realise that the time must be exact to be a match. I found this out by changing all times to General and seeing that the numbers were different. Then i had a problem of making sure the Times were rounded to the same decimal places. Glenn help me alot with this and im begining to understand it.

    The data in Column E (FORMULAS Worksheet) is imported from a .CSV file so unfortunatly alway a different format from the data in the "DATA" Worksheet.

    I can easily Custom format the Times in Column E (FORMULAS Worksheet) but its harder to change the Time format from the "DATA" Worksheet.

    I have changed this now, would these Times now be a match? Or i do require more "jiggery-pokery" to make these a match?

    Thank you for taking the time!
    Attached Files Attached Files

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

    Re: Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    1. Make sure all your dates are in the same format 12hr or 24hr. 06:05 is not 18:05. If I say 06:05, am I talking about 06:05 or 18:05 ??? It's impossible to tell. So keep your dates in the same format.

    Use this

    in F2
    =INDEX(DATA!A$1:A$1000,MATCH(E2,DATA!A$1:A$1000)+IF(LEFT(INDEX(DATA!A$1:A$1000,MATCH(E2,DATA!A$1:A$1000)+5),1)="J",4,5),1)

    and copy down the column
    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 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,647

    Re: Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    There's a more worrying problem. Please look at this and tell me if the number of AAAAAAAAAAAAAAAAAAAAAAAAAAAA rows is correct:

    Excel 2016 (Windows) 32 bit
    A
    1
    03:45
    2
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    3
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    4
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    5
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    6
    A 1000
    7
    J: aaaaaaaaaaaaa
    8
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    9
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    10
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    11
    06:05
    12
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    13
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    14
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    15
    7 2000
    16
    J: aaaaaaaaaaaaa
    17
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    Sheet: DATA

    Because if it is, your required formula will never work.

  7. #7
    Forum Contributor
    Join Date
    02-09-2016
    Location
    West Midlands
    MS-Off Ver
    2016
    Posts
    224

    Re: Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    Quote Originally Posted by AliGW View Post
    The other problem is that there are not even numbers of AAAAAAAAAAA rows between times and J rows - there are four in the first and 3 in the second, so your required formula will not work for the second time.
    Thats the part im stuck with Ali... I cant adjust this Data so my idea was to create a Forumula that finds the Time match then;

    If the 5th Row down from the Matched 'Time' has the first character of "J" return the value of the row above (ie, the 4th row down from the Time Match).
    If the 5th Row down from the Matched 'Time' does not have a "J" as the first character, then return the 5th row down.

    That way no matter which way around the Cell contains a "J" (4th Row or 5th Row) it will always return what im looking for. Which in this case is the Row which is highlighted
    in 'Red' in the "DATA" Worksheet.

    Excuse my explination of what im trying to achieve... i get carried away and realise i can be hard to understand!

    Thanks for taking a look Ali

  8. #8
    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,647

    Re: Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    Did Special-K's formula do the trick? I confess I had not followed your reasoning.

  9. #9
    Forum Contributor
    Join Date
    02-09-2016
    Location
    West Midlands
    MS-Off Ver
    2016
    Posts
    224

    Re: Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    Thanks for taking the time Special K!

    Unfortunatly when i tried that Formula both Cells returned "7 2000" where i need Cell F2 to return A 1000 (the one above) as the 5th Row starts with a letter "J"?

  10. #10
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    but your time in formula sheet is
    15:45:00
    where as in data sheet it is 03:45
    there is no time match then how the result will come
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  11. #11
    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,647

    Re: Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    Your times aren't matching: you've changed the format on the main sheet so that it looks the same as the secondary sheet, but they are still 12 hours apart. Are they meant to be AM or PM?

  12. #12
    Forum Contributor
    Join Date
    02-09-2016
    Location
    West Midlands
    MS-Off Ver
    2016
    Posts
    224

    Re: Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    Yes Ali, thats correct. I think i see what you saying (excuse my lack of Excel wisdom!)

    In the "DATA" Worksheet Cell A6 Starts with an A. This will not start with the same value as A so for the purpose of this problem Cell A6 could start with a B.

    I could try getting it to work a different way as follows, which may help;


    If the 5th Row down from the Matched 'Time' DOESNT start with the character "J" THEN return the value in the 5th Row down (Cell A6 "B 1000" for the 03:45 Time Match)
    If the 5th Row down from the Matched 'Time' DOES start with the character "J" as the first character, then return the Row 4th Row down from the Time Match (Cell A15 "7 2000" for the 06:05 Time Match)

    Does that make it any easier? Again, appologies for poor explination...

  13. #13
    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,647

    Re: Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    I get that now, but that doesn't address the issue of the mismatched times.

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

    Re: Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    1) You're doing something wrong, Im getting both A 1000 and 7 2000.

    2) Again, your times are still not the SAME value.

    FORMULAS times are 03:45PM (15:45) and 06:05PM (18:05).
    DATA times are 03:45 and 06:05
    If you change the format of the times to decimals you will see they are different. They need to be the same or you WON'T get a match.

  15. #15
    Forum Contributor
    Join Date
    02-09-2016
    Location
    West Midlands
    MS-Off Ver
    2016
    Posts
    224

    Re: Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    Quote Originally Posted by AliGW View Post
    Your times aren't matching: you've changed the format on the main sheet so that it looks the same as the secondary sheet, but they are still 12 hours apart. Are they meant to be AM or PM?
    All meant to be PM Ali. To be honest that part i could adjust and make the time Match. Its the other part of the formula that confusses me.

    For the purpose of this example all the lookup valuesare a match, so that part works.

    Ill upload an edited version.
    Attached Files Attached Files

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

    Re: Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    You've now changed something else, A 1000 to B 1000

    The output is now

    B 1000
    7 2000

    It would appear the formula does work.

  17. #17
    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,647

    Re: Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    Special-K's formula seems to be doing exactly what you have requested in your latest attachment. My head is beginning to spin ...

  18. #18
    Forum Contributor
    Join Date
    02-09-2016
    Location
    West Midlands
    MS-Off Ver
    2016
    Posts
    224

    Re: Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    Quote Originally Posted by Special-K View Post
    1) You're doing something wrong, Im getting both A 1000 and 7 2000.

    2) Again, your times are still not the SAME value.

    FORMULAS times are 03:45PM (15:45) and 06:05PM (18:05).
    DATA times are 03:45 and 06:05
    If you change the format of the times to decimals you will see they are different. They need to be the same or you WON'T get a match.

    Sorry!

    Yes this works fine! All the time i wasnt worried about the Time Match part was my downfall! Ill never underestimate the importnace of matching the Time Values again.

    This work perfectly, thank you Special-K!

    Thankyou Ali for taking the time... i appologies on my explinations of what i was trying to achieve...

  19. #19
    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,647

    Re: Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    Thank goodness for that! I thought we were losing the plot ...

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  20. #20
    Forum Contributor
    Join Date
    02-09-2016
    Location
    West Midlands
    MS-Off Ver
    2016
    Posts
    224

    Re: Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    Done and done... Ahhh Ali yes, i did think i was lossing it! Thats lack of sleep

    Onwards and upwards though!... I do really appreciate all your help. Ive never known a more helpfull, friendly Forum.

  21. #21
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,169

    Re: Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    Try

    =IFERROR(IF(AND(MATCH($E2,DATA!$A$1:$A$100,0),INDEX(LEFT(DATA!$A$1:$A$100,1),MATCH($E2,DATA!$A$1:$A$100,0)+6)="J"),INDEX(DATA!$A$1:$A$100,MATCH($E2,DATA!$A$1:$A$100,0)+5),INDEX(DATA!$A$1:$A$100,MATCH(E2,DATA!$A$1:$A$100,0)+4)),"")

    with corrected times !

  22. #22
    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,647

    Re: Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    Glad that you for the result you were looking for eventually. The devil is often in the detail.

  23. #23
    Forum Contributor
    Join Date
    02-09-2016
    Location
    West Midlands
    MS-Off Ver
    2016
    Posts
    224

    Re: Complex LOOKUP and Return Criteria possibly using INDEX/MATCH...

    Thanks John for your time!

    This also seems to work perfectly... it was my mistake with the discrepancy of the 'Times' that was preventing me seeing that 'Special-K's' original Formula worked after all.

    Thank though for helping me

+ 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] VLOOKUP formula with multiple criteria (possibly INDEX/MATCH instead?)
    By Alphabex in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-03-2016, 04:09 AM
  2. Need an array possibly INDEX/MATCH formula with multiple lookup criteria.
    By TheClaw2323 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-25-2015, 09:59 AM
  3. [SOLVED] Combining 3 Formulas: Return all Names that Match Criteria Using Index/Match
    By bchilme in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 09-29-2014, 09:28 AM
  4. Replies: 6
    Last Post: 04-30-2014, 02:42 AM
  5. Index Match using two criteria to return on of criteria values
    By RogueLeader in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-17-2014, 09:50 AM
  6. [SOLVED] Complex index/match lookup
    By rinkjames in forum Excel General
    Replies: 4
    Last Post: 06-10-2012, 01:27 PM
  7. Replies: 1
    Last Post: 08-17-2011, 06:33 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