+ Reply to Thread
Results 1 to 10 of 10

Lowest number in comma separated list from a single cell

  1. #1
    Registered User
    Join Date
    06-18-2015
    Location
    Perth
    MS-Off Ver
    2010
    Posts
    4

    Cool Lowest number in comma separated list from a single cell

    Hi. Hoping someone can pleaI am trying to create a formula that will give me the lowest number from a comma separated list that exists in a single cell.
    I would also like to know which number in the sequence has the lowest number.
    Finally, I would like to find the corresponding value from a second comma separated list.
    The values are not necessarily in an ordered sequence.

    For example.
    A1 contains: 6, 5, 4.3, 3.1, 4, 5
    B1 contains 1, 3, 4, 3, 5.6, 9.7

    I'm trying to find a formula that will give me the lowest value in A1: ie. 3.1 (as the lowest)
    I then need a second formula that will give where in the A1 sequence the lowest occurs: ie. 4 (as the 4th value in the list)
    Finally, I would like to get the corresponding value (ie. 4th value) in this example from a second list that exists in B1: ie. 3

    Have spent a long time trying to solve this unsuccessfully. I would rather a formula solution than a macro as I will need to do this multiple time and manipulate this further.

    Thanks for having a look.

    Cheers
    JWro

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,592

    Re: Lowest number in comma separated list from a single cell

    Here, I've create you UDF that will calculate what you want with delimiter you want.
    Use it as:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Where first word is what you try to calculate (SUM, MAX, MIN, COUNT or AVERAGE)
    A1 is range
    "," is delimiter. In this case ,


    Please Login or Register  to view this content.

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Lowest number in comma separated list from a single cell

    Let me state the obvious...

    If you put each number in a separate cell this would be very easy to do.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Lowest number in comma separated list from a single cell

    Quote Originally Posted by jwrobel View Post
    I'm trying to find a formula that will give me the lowest value in A1
    In C1:

    =AGGREGATE(15,,0+TRIM(MID(SUBSTITUTE(A1,",",REPT(" ",LEN(A1))),1+LEN(A1)*(ROW(INDEX(A:A,1):INDEX(A:A,1+LEN(A1)-LEN(SUBSTITUTE(A1,",",""))))-1),LEN(A1))),1)

    Quote Originally Posted by jwrobel View Post
    I then need a second formula that will give where in the A1 sequence the lowest occurs
    In D1:

    =1+LEN(LEFT(A1,FIND(C1,A1)))-LEN(SUBSTITUTE(LEFT(A1,FIND(C1,A1)),",",""))

    Quote Originally Posted by jwrobel View Post
    Finally, I would like to get the corresponding value (ie. 4th value) in this example from a second list that exists in B1
    In E1:

    =0+SUBSTITUTE(TRIM(MID(SUBSTITUTE(B1," ",REPT(" ",LEN(B1))),(D1-1)*LEN(B1)+1,LEN(B1))),",","")

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  5. #5
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Lowest number in comma separated list from a single cell

    One more
    Array formula entered in C1
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    ***Array formula
    ...confirmed by pressing CTRL+SHIFT+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.

    regular formula in D1
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    and regular formula in E1
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    v A B C D E
    1 6, 5, 4.3, 3.1, 4, 5 1, 3, 4, 3, 5.6, 9.7 3.1 4 3
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Lowest number in comma separated list from a single cell

    I may as well post this...

    Data Range
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    1
    6
    5
    4.3
    3.1
    4
    5
    Min
    Position
    Corresponding
    2
    1
    3
    4
    3
    5.6
    9.7
    3.1
    4
    3


    You can parse the stings using the Text to Columns feature.

    This formula in H2: =MIN(A1:F1)

    This formula in I2: =MATCH(H2,A1:F1,0)

    This formula in J2: =INDEX(A2:F2,I2)

  7. #7
    Registered User
    Join Date
    06-18-2015
    Location
    Perth
    MS-Off Ver
    2010
    Posts
    4

    Re: Lowest number in comma separated list from a single cell

    Thanks to all the posts. Definitely helping already.

    Question 1 - solved. The solutions from A1Key and XOR LX for the first question are awesome.
    Question 2 - when finding which number in the sequence, both solutions gets tripped up by finding a matching digit but not necessarily the matching number. ie. If 1 is the lowest number, it finds the first match of 1 which may be part of a larger number (eg. 12).
    Question 3- A1Key's solution doesn't work when the minimum value is first in the list - not sure why. Also, can't get XOR LX's solution for question 3 to work at all.

    Any further advice available?
    Much appreciated,
    JWro

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Lowest number in comma separated list from a single cell

    The TRIM in my first formula was superfluous:

    =AGGREGATE(15,,0+MID(SUBSTITUTE(A1,",",REPT(" ",LEN(A1))),1+LEN(A1)*(ROW(INDEX(A:A,1):INDEX(A:A,1+LEN(A1)-LEN(SUBSTITUTE(A1,",",""))))-1),LEN(A1)),1)

    Quote Originally Posted by jwrobel View Post
    Question 2 - when finding which number in the sequence, both solutions gets tripped up by finding a matching digit but not necessarily the matching number. ie. If 1 is the lowest number, it finds the first match of 1 which may be part of a larger number (eg. 12).
    Good point.

    =1+LEN(LEFT(A1,FIND(", "&C1&", ", ","&A1&", ")))-LEN(SUBSTITUTE(LEFT(A1,FIND(", "&C1&", ", ","&A1&", ")),",",""))

    Quote Originally Posted by jwrobel View Post
    Question 3. Also, can't get XOR LX's solution for question 3 to work at all.
    Works fine for me. Are you sure you're placing the previous formulas in the specified cells? Also, you might want to elaborate a bit - what results are you getting and for which test strings, for example?

    Regards

  9. #9
    Registered User
    Join Date
    06-18-2015
    Location
    Perth
    MS-Off Ver
    2010
    Posts
    4

    Re: Lowest number in comma separated list from a single cell

    Thanks to all that took the time to provide some help for the above query.
    My question has now become a little more complex.
    sample sheet
    A B C
    1 1,2,3,4,5 2,3,4,6,7
    2 2,4,7 3,4,6
    3 8,4,9,12,12,1,5 1,2,3,6,5,4,7

    I would like to fill in column C with a corresponding list of products of A and B such that C1 = 2,6,12,24,35 (ie. 1x2, 2x3, 3x4, 4x6, 5x7)

    As you can see, not all lists in column A and B have the same length and not all lists are ordered in magnitude.

    I suspect I need to use VBA but not really sure where to start.

    I would greatly appreciate any guidance.
    Thanks.

  10. #10
    Registered User
    Join Date
    06-18-2015
    Location
    Perth
    MS-Off Ver
    2010
    Posts
    4

    Re: Lowest number in comma separated list from a single cell

    After further searching, I think I have solved my own post with the following code:

    CPET1 = ActiveCell.Value
    CPET2 = ActiveCell.Offset(0, 1).Value

    FirstArray = Split(CPET1, ",") ' creates the first array
    SecondArray = Split(CPET2, ",") ' creates the second array

    i = 0
    x = FirstArray(i) ' first value of the first array
    y = SecondArray(i) ' first value of the second array
    CPETminProduct = x * y ' starting point for CPETmin

    ' this section manages arrays of different length by omitting the last values of the larger array
    FirstArrayLength = UBound(FirstArray) + 1
    SecondArrayLength = UBound(SecondArray) + 1
    MinArrayLength = WorksheetFunction.Min(FirstArrayLength, SecondArrayLength)


    For i = 0 To MinArrayLength - 1

    x = FirstArray(i)
    y = SecondArray(i)
    xy = x * y
    If CPETminProduct > xy Then CPETminProduct = xy
    ActiveCell.Offset(0, 2).Value = CPETminProduct

    Next

+ 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. Selecting Lowest Number from Data in a Single Cell Separated by Comma
    By hasanrazaque in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-07-2016, 12:13 AM
  2. [SOLVED] Using comma separated values in a single cell
    By joerobb in forum Excel General
    Replies: 7
    Last Post: 01-16-2015, 08:45 AM
  3. Match a Value from a single-cell, comma separated list
    By secondchild12 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-24-2014, 06:16 PM
  4. Count number appear in single column with comma separated
    By cheeyap91 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-29-2014, 12:38 AM
  5. Macro to create a list of sheets, separated with comma in a single cell
    By manolomana in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-30-2014, 11:00 AM
  6. [SOLVED] Single cell Comma Separated Values to validation list [DIFFICULT QUESTION]
    By jgema in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-31-2013, 08:48 PM
  7. Column/cells to single cell comma separated data?
    By egeorge4 in forum Excel General
    Replies: 1
    Last Post: 04-27-2007, 03:53 PM

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