+ Reply to Thread
Results 1 to 10 of 10

Lookup nearest value

  1. #1
    Registered User
    Join Date
    04-21-2009
    Location
    Nottingham
    MS-Off Ver
    Excel 2003
    Posts
    66

    Lookup nearest value

    Hi all, I understand the VLookup and Hlookup concepts, but I don’t know how to (if possible) lookup a nearest match.

    I have added an example attachment.

    If in E4 – I want to lookup the value of D4, from columns A:B to find the nearest match (4.5 in this instance) and return the value of H (B8) how can I do this?
    Attached Files Attached Files

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

    Re: Lookup nearest value

    Array Formula:

    E4: =INDEX(B1:B26,MATCH(MIN(ABS(D4-A1:A26)),ABS(D4-A1:A26),0))
    committed with CTRL + SHIFT + ENTER

  3. #3
    Registered User
    Join Date
    04-21-2009
    Location
    Nottingham
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: Lookup nearest value

    Thanks D.O - I wonder if it is possible without using an array formula though?

    If I want to use more than one (which I do) they can be quite hefty and slow the file down.

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,053

    Re: Lookup nearest value

    =index($b$1:$b$26;match(d4;$a$1:$a$26;1)+1)
    Never use Merged Cells in Excel

  5. #5
    Registered User
    Join Date
    04-21-2009
    Location
    Nottingham
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: Lookup nearest value

    Magic, thanks very much

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

    Re: Lookup nearest value

    zbor, that wouldn't work if D4 were say 4.1

    KevinThomas, it will depend in part on how many variants of this calculation you're performing... the simplest non-array approach would be to store the ABS vaiance of A1:A26 to D4 in C1:C26 and then use a standard INDEX/MATCH as outlined by zbor

    =INDEX(B1:B26,MATCH(MIN(C1:C26),C1:C26,0))

    You can do this in non-array form without helpers

    =INDEX(B1:B26,MATCH(MIN(INDEX(ABS(A1:A26-D4),0)),INDEX(ABS(A1:A26-D4),0),0)

    but this is not efficient.

  7. #7
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,053

    Re: Lookup nearest value

    Why not? Work for me....

    It will find lowest value and +1 will bring propper result

    Edit: you are right.. but this might work:

    =IF(ISNA(MATCH(D4;$A$1:$A$26;0));INDEX($B$1:$B$26;MATCH(D4;$A$1:$A$26;1)+1);VLOOKUP(D4;$A$1:$B$26;2;TRUE))
    Last edited by zbor; 06-09-2009 at 04:28 AM.

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

    Re: Lookup nearest value

    No that would not work either. The key is that you must calculate the actual variance of the values to the criteria and match the smallest variance.

  9. #9
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Lookup nearest value

    Please Login or Register  to view this content.
    Confirmed with CSE works!

    I'm sure somebody will optimise the formula ;-)
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


  10. #10
    Registered User
    Join Date
    03-30-2010
    Location
    india
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Due date reminder

    Sir, i have auto finance company and have more than 750 customers. i want creat due date reminder register.

    Installment due in particular day those customers.

    Please help me.

    With regard

+ 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