+ Reply to Thread
Results 1 to 9 of 9

Return column title based on smallest value by row?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-14-2012
    Location
    Belgium/UK
    MS-Off Ver
    Excel 2003
    Posts
    111

    Return column title based on smallest value by row?

    Hello,

    C2 to G2 have values in them. Is there a way to determine the lowest value ( other then SMALL function) and then return values to the according 1:1 row?

    Example:

    Name Test1 Test2 Test3 Test4 Test5 Weak Expected value
    CAR1 66.7% 40.0% 100.0% 71.4% 50.0% =formula Test2
    CAR2 100.0% 20.0% 40.0% 57.1% 16.7% Test5
    CAR3 33.3% 0.0% 40.0% 57.1% 0.0% Test2,Test5

    sample2.xlsx
    Regards,

    RR

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

    Re: Return column title based on smallest value by row?

    Here's a start..

    In M2 and filled down
    =INDEX(C$1:G$1,MATCH(MIN(C2:G2),C2:G2,0))

    Now this will only return the first instance of the lowest value.
    Getting the multiple results like you show in M4 will be much much more complicated.
    Will probably require VBA.

  3. #3
    Forum Contributor
    Join Date
    07-14-2012
    Location
    Belgium/UK
    MS-Off Ver
    Excel 2003
    Posts
    111

    Re: Return column title based on smallest value by row?

    Thank you for the reply Jonmo1,

    It will get me started at least. In the real data we have several times where we would get 3 or even 5 results back, so it would be handy but I can work with this

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

    Re: Return column title based on smallest value by row?

    Quote Originally Posted by realrookie View Post
    In the real data we have several times where we would get 3 or even 5 results back, so it would be handy
    Are you familiar with macros/VBA ?

    This can be done with a VBA function. Want to try it?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

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

    Re: Return column title based on smallest value by row?

    You're welcome.

  6. #6
    Forum Contributor
    Join Date
    07-14-2012
    Location
    Belgium/UK
    MS-Off Ver
    Excel 2003
    Posts
    111

    Re: Return column title based on smallest value by row?

    I am somewhat familiar with VBA. Everything I learn has come from here. Always happy to learn more

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

    Re: Return column title based on smallest value by row?

    With your file open, copy the VBA code at this link and paste it into a general module.

    https://www.excelforum.com/showthread.php?p=3096647

    Then...

    Data Range
    A
    B
    C
    D
    E
    F
    G
    H
    I
    1
    Name
    Test1
    Test2
    Test3
    Test4
    Test5
    Expected value
    2
    CAR1
    66.7%
    40.0%
    100.0%
    71.4%
    50.0%
    Test2
    3
    CAR2
    100.0%
    20.0%
    40.0%
    57.1%
    16.7%
    Test5
    4
    CAR3
    33.3%
    0.0%
    40.0%
    57.1%
    0.0%
    Test2, Test5
    5
    ------
    ------
    ------
    ------
    ------
    ------
    ------
    ------
    ------


    This array formula** entered in I2 and copied down:

    =concatall(IF(C2:G2=MIN(C2:G2),C$1:G$1,""),", ")

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  8. #8
    Forum Contributor
    Join Date
    07-14-2012
    Location
    Belgium/UK
    MS-Off Ver
    Excel 2003
    Posts
    111

    Re: Return column title based on smallest value by row?

    Hello Tony,

    How exactly do I enter the array formula?
    Type =concatall(IF(C2:G2=MIN(C2:G2),C$1:G$1,""),", ") into the cell and hit CRTL+SHIFT and ENTER? Because when I do that it enters that formula as text?

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

    Re: Return column title based on smallest value by row?

    That sounds like the cell is formatted as text.

    Change the cell format to General then re-enter the formula.

    Array formulas are entered differently than a regular formula. After you type in a regular formula you hit the ENTER key. With an array formula you must use a combination of keys. Those keys are the CTRL key, the SHIFT key and the ENTER key. That is, hold down both the CTRL key and the SHIFT key then hit the ENTER key.

    When done properly Excel will enclose the formula in squiggly brackets { }. You can't just type these brackets in, you must use the key combo to produce them. Also, anytime you edit an array formula it must be re-entered as an array using the key combo.

    Here's your file with this implemented.
    Attached Files Attached Files

+ 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. Replies: 2
    Last Post: 02-02-2015, 10:19 PM
  2. Looking to return column title of second largest value
    By JoJenkins in forum Excel General
    Replies: 1
    Last Post: 02-05-2014, 05:30 PM
  3. Return the Title of a column if the column is the highest column with data
    By williamspage in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 08-22-2013, 10:05 AM
  4. Replies: 4
    Last Post: 10-19-2012, 12:09 PM
  5. Replies: 5
    Last Post: 09-29-2011, 06:39 AM
  6. Return column title if value present
    By ChrisMattock in forum Excel General
    Replies: 13
    Last Post: 08-14-2009, 11:48 AM
  7. Find max value in a row and return column title
    By Jshendel in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-21-2006, 12:25 PM

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