+ Reply to Thread
Results 1 to 5 of 5

lowest via highest nums!

  1. #1
    stewart08
    Guest

    lowest via highest nums!

    hi excelers, I will try to make this question clear:

    how does one find the lowest or highest numbers from other numbers i.e.

    (highest num) "25"
    (lowest num) "5"

    which number 6 or 20 match closest to the two numbers above!

    should result in = "6" as its the closet by digits to lowest num 5.
    but 20 is not chosen as its 5 digits away from 25.

    hope this is clear
    Last edited by stewart08; 04-05-2008 at 11:55 AM.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967
    Try the attached. There's a user defined function called Nearest used in cell E2 which takes 4 arguments. You can see the code by hitting Alt F11 and looking at module1.
    Attached Files Attached Files
    Martin

  3. #3
    stewart08
    Guest
    thanks for the reply mrice.

    can this be do without visual basic code as I donot want to get into code at this point.

    thanks

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    If your lowest number is in A1 and your highest number in B1,

    =IF(MIN(ABS(A1-D1),ABS(B1-D1)) < MIN(ABS(A1-C1),ABS(B1-C1)), D1, C1)

    will select between C1 and D1, the number that is closest to the boundry values.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    stewart08
    Guest
    thanks again mikerickson

    this forum is amazing very fast reply too....

+ 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