+ Reply to Thread
Results 1 to 7 of 7

making a max function for the hole values NOT in the range

  1. #1
    Registered User
    Join Date
    11-15-2009
    Location
    Israel
    MS-Off Ver
    Excel 2007
    Posts
    4

    Question making a max function for the hole values NOT in the range

    this function should return a complete numeric value lower then the max number in range and the highist possible value MISSING from the range

    for exemple:
    if the numbers in the range are 1, 9, 4 and 8 the result shold be 7
    7 is lower then 9 (9 is the max value in range), a hole number (i dont want to see fractions) and as high as it gets and still not be one of the numbers in the range

    i do not have programing/macro abilities in my excel (atlist non that i know of)
    and i need to show the 3 highist number not chosen yet (i will use it 3 time and every time add the result to the range for the next one)

    i can artificially add a max value to the range in order to limit it as i like, or the function can get a max value in separate

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: making a max function for the hole values NOT in the range

    Hi

    Not sure how you want this to work, but here's a start.

    Enter your numbers in the range A1:A4.

    Put the function below in a general module

    Please Login or Register  to view this content.
    In a cell enter: =getmaxmissing(A1:A4)

    HTH

    rylo

  3. #3
    Registered User
    Join Date
    11-15-2009
    Location
    Israel
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: making a max function for the hole values NOT in the range

    tnx
    i just changed the 2nd line to:
    getmaxmissing = WorksheetFunction.Min(rng) - 1
    and it works butifully ^^

    EDIT:

    i played a little with your function and ended up with this:

    Please Login or Register  to view this content.
    just in case some more people find it usefull

    EDIT:

    sorry about that, ive added code tags now
    Last edited by Stoi; 11-16-2009 at 03:32 AM.

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: making a max function for the hole values NOT in the range

    This CSE formula will return the number you want from the range A1:A10. If the numbers in the range might exceed 100, change the argument of INDIRECT.

    =MAX(A1:A10) - MATCH(FALSE, ISNUMBER(MATCH(MAX(A1:A10)-ROW(INDIRECT("1:100")), A1:A10 ,0)), 0)

    This should be entered with Ctrl-Shift-Enter (Cmd+Return for Mac)
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Registered User
    Join Date
    11-15-2009
    Location
    Israel
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: making a max function for the hole values NOT in the range

    Quote Originally Posted by mikerickson View Post
    This CSE formula will return the number you want from the range A1:A10. If the numbers in the range might exceed 100, change the argument of INDIRECT.

    =MAX(A1:A10) - MATCH(FALSE, ISNUMBER(MATCH(MAX(A1:A10)-ROW(INDIRECT("1:100")), A1:A10 ,0)), 0)

    This should be entered with Ctrl-Shift-Enter (Cmd+Return for Mac)
    can you explain this plz? ive tryed it and gut #N/A, i have no idea why.

    useing the VB code make my excel be a bit laggish, so i'll appreciate it if thers a better way to do it

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: making a max function for the hole values NOT in the range

    ROW(INDIRECT("1:100")
    is the array {1; 2; 3; ...; 100}
    so
    MAX(A1:A10)-ROW(INDIRECT("1:100"))
    is the array of numbers less than MAX(A1:A10) in decending order.
    Note that if N is in the descending array and its index in that array is i then i+N=MAX(A1:A10)

    MATCH(MAX(A1:A10)-ROW(INDIRECT("1:100")), A1:A10,0)
    is an array that returns #N/A if the descending number is not in A1:A10 and its index otherwise.

    ISNUMBER(MATCH(MAX(A1:A10)-ROW(INDIRECT("1:100")), A1:A10,0) is the above array, converted in to TRUE/FALSE values, TRUE if the number is in A1:10, FALSE otherwise.

    MATCH(FALSE, ISNUMBER(MATCH(MAX(A1:A10)-ROW(INDIRECT("1:100")), A1:A10,0)), 0) returns the index of the first FALSE value in that array.
    That is it returns the index of the highest integer in the descending array that is not in A1:A10.

    So the final formula
    MAX(A1:A10) - MATCH(FALSE, ISNUMBER(MATCH(MAX(A1:A10)-ROW(INDIRECT("1:100")), A1:A10,0)), 0)
    is the highest number that is both less than MAX(A1:A10) and not in A1:A10, which is the desired value.

    This formula needs to be entered as an array formula. Copy paste the formula from the website into the formula bar of the spreadsheet. With the cursor in the formula editing box, press Ctrl-Shift-Enter (Cmd+Return for Mac)

  7. #7
    Registered User
    Join Date
    11-15-2009
    Location
    Israel
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: making a max function for the hole values NOT in the range

    tnx alot

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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