+ Reply to Thread
Results 1 to 16 of 16

Find largest number in string containing multiple numbers

  1. #1
    Registered User
    Join Date
    05-25-2010
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    26

    Find largest number in string containing multiple numbers

    Say if I had a cell which contained:

    35.328, 32.086, 33.326, 34.479, 34.268, 33.953, 32.497, 31.37, 30.963, 29.252, 29.152, 28.655
    (all in one cell)
    and the cells do not always necessarily have exactly this amount of numbers in them, but up to a maximum of 24 different numbers.

    How would I be able to return the largest number in each cell??

    Thanks for any help!

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Find largest number in string containing multiple numbers

    Split the cell using Text to columns, then use the MAX function.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Find largest number in string containing multiple numbers

    you could try a user-defined function (I'm assuming there are only commas, spaces and numbers in the text string):

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    05-25-2010
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Find largest number in string containing multiple numbers

    Quote Originally Posted by NickyC View Post
    you could try a user-defined function (I'm assuming there are only commas, spaces and numbers in the text string):

    Please Login or Register  to view this content.
    Awesome, that seems to be just what I need, thanks so much!

  5. #5
    Registered User
    Join Date
    05-25-2010
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Find largest number in string containing multiple numbers

    Also just one more thing, how would I find the xth number in the list? e.g. 9nth number listed.
    Would be easy if they all had the same number of decimal places..

  6. #6
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Find largest number in string containing multiple numbers

    As long as the numbers are each separated by a comma and a space...
    A1: 35.328, 32.086, 33.326, 34.479, 34.268, 33.953, 32.497, 31.37, 30.963, 29.252, 29.152, 28.655
    B1: n-th largest value to find....3

    This regular formula will return the n-th largest value in the text.
    EDITED: REPLACE MY ORIGINAL FORMULA (WHICH DID NOT FIND THE LAST NUMERIC VALUE...WITH THIS TWEAKED (AND EQUALLY UGLY) FORMULA
    Please Login or Register  to view this content.
    (Yeah...I know....ugly as a mud fence, but it works )

    In the above example, that formula returns: 34.268 (the 3rd largest value)

    If B1: 1
    The returned value is: 35.328 (the largest value)

    Is that something you can work with?
    Last edited by Ron Coderre; 01-18-2012 at 09:17 PM.
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  7. #7
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Find largest number in string containing multiple numbers

    Try this,

    For MAX, Confirmed with CTRL+SHIFT+ENTER

    =MAX(IFERROR(0+TRIM(MID(SUBSTITUTE(","&A1,",",REPT(" ",LEN(A1))),(ROW(A$1:A$200)*LEN(A1))-1,LEN(A1))),0))

    For xth number

    =INDEX(0+TRIM(MID(SUBSTITUTE(","&A1,",",REPT(" ",LEN(A1))),(ROW(A$1:A$200)*LEN(A1))-1,LEN(A1))),x)

    Change x to a number

    EDIT:

    for the nth LARGEST

    =LARGE(IFERROR(--TRIM(MID(SUBSTITUTE(","&A1,",",REPT(" ",LEN(A1))),(ROW(A$1:A$200)*LEN(A1))-1,LEN(A1))),0),n)


    Array Entered.
    Last edited by Haseeb Avarakkan; 01-18-2012 at 09:12 PM.
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  8. #8
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Find largest number in string containing multiple numbers

    OK...Here's what's depressing...I've got that approach in my formula stash, but never even checked!
    (Really...why do I bother having a stash if I don't even use it)

    Anyway...With
    A1: 35.328, 32.086, 33.326, 34.479, 34.268, 33.953, 32.497, 31.37, 30.963, 29.252, 29.152, 28.655
    B1: the n-th largest value to find

    Using the variation I've got stashed, here's a regular (non-array) version:
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    05-25-2010
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Find largest number in string containing multiple numbers

    Thanks for the efforts guys, but I just meant nth number chronologically, (not ascending or descending but simply listed from left to right)!
    Cheers

  10. #10
    Registered User
    Join Date
    05-25-2010
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Find largest number in string containing multiple numbers

    Quote Originally Posted by Haseeb A View Post
    Try this,


    For xth number

    =INDEX(0+TRIM(MID(SUBSTITUTE(","&A1,",",REPT(" ",LEN(A1))),(ROW(A$1:A$200)*LEN(A1))-1,LEN(A1))),x)
    Thanks I think this mgiht work, but what is the ROW(A$1:A$200) meant to reference?

  11. #11
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Find largest number in string containing multiple numbers

    Quote Originally Posted by Snowtoad View Post
    Thanks for the efforts guys, but I just meant nth number chronologically, (not ascending or descending but simply listed from left to right)!
    Cheers
    HAH! That's funny...
    Here you go:
    With
    A1: 35.328, 32.086, 33.326, 34.479, 34.268, 33.953, 32.497, 31.37, 30.963, 29.252, 29.152, 28.655
    B1: the n-th value to find...3

    This regular formula returns that value:
    Please Login or Register  to view this content.
    In that example, the formula returns: 33.326 (the 3rd value)

    Does that help?
    Last edited by Ron Coderre; 01-18-2012 at 09:49 PM.

  12. #12
    Registered User
    Join Date
    05-25-2010
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Find largest number in string containing multiple numbers

    Yep, that works, thanks so much!

  13. #13
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Find largest number in string containing multiple numbers

    Your title suggests Max not Nth.

    VBA UDFs could be
    Please Login or Register  to view this content.
    Enter in Excel
    Please Login or Register  to view this content.

    Please Login or Register  to view this content.
    Enter in Excel
    Please Login or Register  to view this content.
    For reference only, best to use native formula when ever possible.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  14. #14
    Registered User
    Join Date
    05-25-2010
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Find largest number in string containing multiple numbers

    Yeah first it was max, NickyC found a solution, then Haseeb and Ron found a solution for the Nth, thanks!

  15. #15
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Find largest number in string containing multiple numbers

    I think you will find that my function "GetMax" for max is a tad more efficient.

    If you have blank rows use like so
    Please Login or Register  to view this content.
    Last edited by Marcol; 01-19-2012 at 06:47 AM.

  16. #16
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Find largest number in string containing multiple numbers

    Marcol - I agree
    I have never used Split before, but I'm sure I will find it handy in future - thanks

+ 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