+ Reply to Thread
Results 1 to 13 of 13

Match value that is closest in value and also fulfills other criteria

  1. #1
    Registered User
    Join Date
    05-19-2010
    Location
    Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    9

    Match value that is closest in value and also fulfills other criteria

    Hey Guys,

    im having the following problem. I want to match a value that is closest in value to the lookup value and also fulfils some other criteria.

    The first criteria is a number that I want to match with the item that is closest in value in cell AL457. For this, the following formula works.

    Please Login or Register  to view this content.
    But now I want to find the cell that is closest in value and fulfills another criteria, which is in cell DT457. However, if I use the following formula below, this only works if the item that is closest in value also fulfills the criteria. If it doesnt, I get #N/A. Lets say that the first item that fulfills the criteria is 3rd closest in value, than thats the item I want to know the row of.

    Please Login or Register  to view this content.
    Help would be greatly appriciated!!!!

    Thanks!

    Oh, Excel 2007 btw
    Last edited by osmdian2; 05-20-2010 at 06:14 AM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Match value that is closest in value and also fulfills other criteria

    Maybe you mean?

    Please Login or Register  to view this content.
    this find the position where both DS4:DS1700 equals the value in DT457 and where the MIN difference is coincides.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    05-19-2010
    Location
    Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Match value that is closest in value and also fulfills other criteria

    Thanks, but the formula didnt work, even if I hit shift+ctrl+enter. The thing is that the item with the closest value might not be the one that fulfills the criteria in DT457. Lets say the first item that fulfulls the criteria in DT457 is the 3rd closest in value and the two that are closer dont fulfill the criteria. What formula would work in this case?

    THX!

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Match value that is closest in value and also fulfills other criteria

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!

  5. #5
    Registered User
    Join Date
    05-19-2010
    Location
    Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Match value that is closest in value and also fulfills other criteria

    Ok, thanks for the tip, I attached a file with the problem. Hope that everything is clear!
    Attached Files Attached Files

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Match value that is closest in value and also fulfills other criteria

    Does this work?

    Please Login or Register  to view this content.
    in E4 and confirmed with CTRL+SHIFT+ENTER and copied down.

  7. #7
    Registered User
    Join Date
    05-19-2010
    Location
    Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Match value that is closest in value and also fulfills other criteria

    Hey NBVC, thanks for your efforts, but this returns "item 1" in E5, where it should return "item 5".

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Match value that is closest in value and also fulfills other criteria

    For me it returned Item 5
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    05-19-2010
    Location
    Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Match value that is closest in value and also fulfills other criteria

    Hey NBVC,

    thanks, now it works for me. However, I dont really understand what the formula does exactly which is why I am having trouble to include the additional criteria. I attached the file again with my attempt to solve it with an AND function (marked in orange), but it doesnt give the right result. Would be great if you could have another look at it!

    Thanks!
    Attached Files Attached Files

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Match value that is closest in value and also fulfills other criteria

    Okay, try this instead:

    Please Login or Register  to view this content.
    confirmed with CTRL+SHIFT+ENTER, not just ENTER and copied down.

    Note: In Array formulas, you use * between conditions to represent AND()

  11. #11
    Registered User
    Join Date
    05-19-2010
    Location
    Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Match value that is closest in value and also fulfills other criteria

    Hey NBVC,

    thanks a lot, already works almost perfect! However, when there should be no match, because there is no item that fulfills the PE Firm=1 and the Industry criteria, I get "Item 1" where I would like to get "N/A" or something because I need to know when there is no match. Tried to figure it out myself but Im still not sure how the formula works exactly...

    I attached the file again with an example that should give N/A.

    Thx in advance!
    Attached Files Attached Files

  12. #12
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Match value that is closest in value and also fulfills other criteria

    Profile implies XL2003 whereas file implies XL2007 (or later).

    If using exclusively in XL2007+ environment why not add a pre-emptive COUNTIFS test to first determine valid results exist ?

    IF(OR(B5="";COUNTIFS($D$4:$D$8;1;$G$4:$G$8;F5)=0);"N/A";...etc...)

  13. #13
    Registered User
    Join Date
    05-19-2010
    Location
    Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Match value that is closest in value and also fulfills other criteria

    I dont know how you did it, but it works like a charm! Thanks a lot to both of you! Will mark this thread as solved.

+ 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