+ Reply to Thread
Results 1 to 12 of 12

How to find the closest number in range

  1. #1
    Registered User
    Join Date
    09-26-2015
    Location
    Estonia
    MS-Off Ver
    2007
    Posts
    10

    How to find the closest number in range

    Hi

    I have a range of numbers 560, 800, 976, 1012 and I need to find which one is the closest to 1005. I know that it is 1012, but I need to find it with a proper function.

    I've tried vlookup and other functions, but I guess something is missing.

    Any help would be appreciated, thanks!

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

    Re: How to find the closest number in range

    Do you mean the closest either + or - ?
    LIke if the number was say 985, would the closest then be 976 ?

  3. #3
    Registered User
    Join Date
    09-26-2015
    Location
    Estonia
    MS-Off Ver
    2007
    Posts
    10

    Re: How to find the closest number in range

    The closest in general, I guess where the range between 2 numbers is the smallest.

    For example if we had the number 995 and range of 976 and 998 then the one that we are looking for is 998.

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

    Re: How to find the closest number in range

    I gave a poor example, I since edited my post.
    If it was 985, would the closest then be 976.

    But I think you do mean either higher or lower..

    Try this array formula entered with CTRL + SHIFT + ENTER

    =INDEX($A$1:$A$4,MATCH(MIN(ABS(C1-$A$1:$A$4)),ABS(C1-$A$1:$A$4),0))

    A1:A4 is your range, C1 is the number of interest.

  5. #5
    Registered User
    Join Date
    09-26-2015
    Location
    Estonia
    MS-Off Ver
    2007
    Posts
    10

    Re: How to find the closest number in range

    Doesn't seem to be working

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: How to find the closest number in range

    Did you enter with CNTRL SHFT ENTER?

    to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  7. #7
    Registered User
    Join Date
    09-26-2015
    Location
    Estonia
    MS-Off Ver
    2007
    Posts
    10

    Re: How to find the closest number in range

    Yes, I used it the first time. I've tried 3 more times now, says an error. Not sure what to do :D

  8. #8
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: How to find the closest number in range

    Here's an example
    Attached Files Attached Files

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

    Re: How to find the closest number in range

    What error?

    Post the exact formula you tried (I just made up ranges for my example, your ranges are probably different)

    Might be best if you could attach a sample book

    Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  10. #10
    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,207

    Re: How to find the closest number in range

    Post a file: I have just tested the formula and it works OK.

  11. #11
    Registered User
    Join Date
    09-26-2015
    Location
    Estonia
    MS-Off Ver
    2007
    Posts
    10

    Re: How to find the closest number in range

    Thank you, works now. I opened up a new excel worksheet and everything was fine.

    Thanks!

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

    Re: How to find the closest number in 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. Find Highest or Closest number from list
    By ChrisKustom in forum Excel Formulas & Functions
    Replies: 21
    Last Post: 08-10-2013, 08:41 AM
  2. [SOLVED] Find a number closest to 30 in a range with one more criteria (criteria includes text)
    By Sarangsood in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-22-2013, 01:16 PM
  3. Find the closest number
    By xyba in forum Excel General
    Replies: 9
    Last Post: 10-21-2010, 04:20 AM
  4. find closest date (number) in a range
    By wamp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-23-2010, 01:50 PM
  5. Find Number Closest to Zero
    By snapa in forum Excel General
    Replies: 2
    Last Post: 12-04-2009, 05:34 PM
  6. Find closest value in a range
    By msbing916 in forum Excel General
    Replies: 2
    Last Post: 11-19-2009, 11:24 AM
  7. Find the closest match to a reference number in a row of unsorted
    By Nick Krill in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-01-2006, 04:35 PM
  8. [SOLVED] find closest match to a reference number in a row of numbers
    By Nick Krill in forum Excel General
    Replies: 4
    Last Post: 12-21-2005, 08:00 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