+ Reply to Thread
Results 1 to 15 of 15

Concatenate if other column value is non-blank or non-zero BUT IN DESCENDING ORDER

  1. #1
    Registered User
    Join Date
    03-13-2013
    Location
    Athens, Greece
    MS-Off Ver
    Excel 2007, Excel 2010
    Posts
    30

    Concatenate if other column value is non-blank or non-zero BUT IN DESCENDING ORDER

    Hello,
    In column A I have blank cells or numbers (could be zero as well)
    In column B I have names, e.g. Peter, John, Mary etc

    For example let's have 3, 0, "", 4, 4, 6, 0, 5, "", 1 in column A
    and Peter, John, Mary, Kate, Alan, Nick, George, Jenny, Tony, Helen

    I am looking for a way cell C1 will give me the names that have a non-zero or non-blank cell next to them BUT IN A DESCENDING ORDER according to the value in column B, separated by commas. That would be Nick, Jenny, Kate, Alan, Peter, Helen
    Nick comes first because he has the highest value (6), Jenny comes 2nd because she has the 2nd highest value, Kate and Alan come next...and so on

    If it is any help this is the function I have been using but does not deal with the DESCENDING ORDER problem. A function would be great but anything you can come up would also be great

    Please Login or Register  to view this content.
    Thanks a lot
    Last edited by Petros Georgilas; 12-05-2014 at 04:32 AM.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Concatenate if other column value is non-blank or non-zero BUT IN DESCENDING ORDER

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Valued Forum Contributor
    Join Date
    06-19-2010
    Location
    Holywell, N Wales, UK
    MS-Off Ver
    Excel 2013
    Posts
    470

    Re: Concatenate if other column value is non-blank or non-zero BUT IN DESCENDING ORDER

    Perhaps a different approach may give you another idea? This simply sorts the data and extracts the data into the string. I have not written it as a function but you could do if required. It is easily modified for Ascending order by changing:

    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    The disadvantage without a bit of additional work is that it changes the order of your data.

    Please Login or Register  to view this content.
    If this was helpful then please click the small star icon at the bottom left of my post. A little appreciation goes a long way.

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Concatenate if other column value is non-blank or non-zero BUT IN DESCENDING ORDER

    Hi Petros,

    Welcome to the Forum

    Please Login or Register  to view this content.

    BTW:=Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  5. #5
    Registered User
    Join Date
    03-13-2013
    Location
    Athens, Greece
    MS-Off Ver
    Excel 2007, Excel 2010
    Posts
    30

    Re: Concatenate if other column value is non-blank or non-zero BUT IN DESCENDING ORDER

    Thank you very much!

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Concatenate if other column value is non-blank or non-zero BUT IN DESCENDING ORDER

    You're welcome!

    *Don't forget to put the code tags around your code - just edit your post - highlight the code and click on the #

  7. #7
    Registered User
    Join Date
    03-13-2013
    Location
    Athens, Greece
    MS-Off Ver
    Excel 2007, Excel 2010
    Posts
    30

    Re: Concatenate if other column value is non-blank or non-zero BUT IN DESCENDING ORDER

    Hello Bernie. I think I realized a disadvantage. It only works with positive integers. Is there a way around so that it works with all kinds of numbers? Negatives are not a big problem but I need non-integers.
    Thank you
    Last edited by Petros Georgilas; 12-05-2014 at 05:16 AM.

  8. #8
    Registered User
    Join Date
    03-13-2013
    Location
    Athens, Greece
    MS-Off Ver
    Excel 2007, Excel 2010
    Posts
    30

    Re: Concatenate if other column value is non-blank or non-zero BUT IN DESCENDING ORDER

    Hello again xladept,
    your solution is great too but I think it also has one disadvantage.
    If I understand correctly it works with one range. That means that the two columns have to be next to each other, right?
    I think that it does not work with negative values which is not a big problem at the moment.
    For the example it is fine. But for my purpose the columns are not next to each other
    Can I define two separate ranges?
    Thank you
    Last edited by Petros Georgilas; 12-05-2014 at 05:16 AM.

  9. #9
    Registered User
    Join Date
    03-13-2013
    Location
    Athens, Greece
    MS-Off Ver
    Excel 2007, Excel 2010
    Posts
    30

    Re: Concatenate if other column value is non-blank or non-zero BUT IN DESCENDING ORDER

    Hello barryleajo,
    thanks for the answer. However, sorting them is not a good idea because in the actual file I am working I need the columns to remain as they are.
    Thanks

  10. #10
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Concatenate if other column value is non-blank or non-zero BUT IN DESCENDING ORDER

    Give this version a try - tied cells needed to be handled differently... and you can set the limit, either hard coded or using a specific calculated value, like

    dLimit = Application.Average(SrcRng)

    to only extract values above the average - see the comments in the code....

    Please Login or Register  to view this content.
    Last edited by Bernie Deitrick; 12-05-2014 at 10:23 AM.

  11. #11
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Concatenate if other column value is non-blank or non-zero BUT IN DESCENDING ORDER

    For non-contiguous ranges:

    Please Login or Register  to view this content.
    *Thanks for the rep!
    Last edited by xladept; 12-05-2014 at 02:54 PM. Reason: To order negative's

  12. #12
    Registered User
    Join Date
    03-13-2013
    Location
    Athens, Greece
    MS-Off Ver
    Excel 2007, Excel 2010
    Posts
    30

    Re: Concatenate if other column value is non-blank or non-zero BUT IN DESCENDING ORDER

    Thank you Bernie. This seems to work great. I am not sure I understand the point about tied cells. If dlimit is set to 0 won't it work for absolutely equal values? Probably there is sth I do not understand.
    By the way I made a small modification. I changed diff to diffv(v for vertical) and added diffh (horizontal so that it handles ranges that may have the same line values)
    Thanks again

  13. #13
    Registered User
    Join Date
    03-13-2013
    Location
    Athens, Greece
    MS-Off Ver
    Excel 2007, Excel 2010
    Posts
    30

    Re: Concatenate if other column value is non-blank or non-zero BUT IN DESCENDING ORDER

    Thank you xladept! This looks perfect!

  14. #14
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Concatenate if other column value is non-blank or non-zero BUT IN DESCENDING ORDER

    My point about tied cells was just that they need to be handled differently in code. Last time, we simply counted down the integers from the max value to 0 - but now we need to find the largest, then the second largest, etc. and all the cells that are tied with those values, if any. But if there are ties, then the nth largest and nth +1 largest are the same, so finding all the tied cells would mean finding the same values twice - so my code handles it, just differently. So, if there cannot be ties, then we would handle it differently still, just indexing off the nth largest value and directly finding its corresponding value.

  15. #15
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Concatenate if other column value is non-blank or non-zero BUT IN DESCENDING ORDER

    You're welcome and thanks for the rep!

+ 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: 5
    Last Post: 05-29-2014, 11:55 AM
  2. [SOLVED] Sort by descending order, but the blank spaces come on top
    By billj in forum Excel General
    Replies: 3
    Last Post: 07-18-2013, 04:18 PM
  3. Replies: 14
    Last Post: 04-17-2012, 05:18 PM
  4. Pivot table to show certain column in descending order
    By rushdenx1 in forum Excel General
    Replies: 1
    Last Post: 01-04-2012, 05:32 AM
  5. [SOLVED] Date in descending order to come up automatically in a column?
    By Snugglebums in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-11-2005, 12:06 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