+ Reply to Thread
Results 1 to 9 of 9

Cells that conditionally displays a concatenated list of other cells' contents

  1. #1
    Registered User
    Join Date
    04-05-2017
    Location
    Houston, TX
    MS-Off Ver
    2016
    Posts
    57

    Cells that conditionally displays a concatenated list of other cells' contents

    I didn't really know how to describe this problem in the title but what I want to do is as follows:

    I have a table of with a number of rows and columns where the rows represent document numbers and the columns represent months. For each document number/month intersection the cell value can be red, green or left blank. I want to have a second table that has the colors as rows and months as columns and the intersecting cells list all of the document numbers from the original table where the color and month also intersect. It's a little confusing so I've attached an example worksheet showing the intended result. The top table shows where the results would be displayed and the bottom table shows where the data would be manually entered.

    I've already come up with a way to accomplish this using VBA but was hoping to do it without using a macro. Named ranges, tables, etc. are acceptable.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Cells that conditionally displays a concatenated list of other cells' contents

    If you really mean it that you're using Office 2016, you have a function named TEXTJOIN which could do this.

    C2: =TEXTJOIN(CHAR(10),1,LEFT($B$6:$B$11,255*(C$6:C$11=$B2)))

    Fill C2 down into C3, then select C2:C3 and fill right into D2:H3.

  3. #3
    Registered User
    Join Date
    04-05-2017
    Location
    Houston, TX
    MS-Off Ver
    2016
    Posts
    57

    Re: Cells that conditionally displays a concatenated list of other cells' contents

    hrlngrv's solution seems to be working. I'm not 100% on how it works though. What does LEFT($B$6:$B$11,255*(C$6:C$11=$B2)) do and more specifically the part of the function after 255? I believe 255 is a character limit so I don't quite understand its role here.

  4. #4
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Cells that conditionally displays a concatenated list of other cells' contents

    You want to concatenate all the entries in B6:B11 for which the corresponding entries in the same rows in C6:C11 equal the value in B2. (C$6:C$11=$B2) returns an array of TRUE and FALSE depending on whether cells in C6:C11 equal B2. 255*(C$6:C$11=$B2) then returns an array of 255 or 0 because TRUE is converted to 1 and FALSE to 0 when used as arithmetic operands. LEFT($B$6:$B$11,255*(C$6:C$11=$B2)) then returns an array of values from B6:B11 or "" (empty string) depending on whether 255*(C$6:C$11=$B2) is 255 or 0, which in turn depends on whether cells in C6:C11 equal B2.

    When TEXTJOIN's 2nd argument is 1 or TRUE, it skips blank/empty strings in its 3rd and subsequent arguments.

  5. #5
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,427

    Re: Cells that conditionally displays a concatenated list of other cells' contents

    C2 array formula

    HTML Code: 
    Attached Files Attached Files

  6. #6
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Cells that conditionally displays a concatenated list of other cells' contents

    Textjoin only available in MS 365 and Excel 2019
    https://support.microsoft.com/en-us/...3-0e8fc845691c

    This also work without using a macro.
    =TEXTJOIN(CHAR(10),,REPT($B$6:$B$11,C$6:C$11=$B2))

    And without Textjoin but limit to 15 digits number result

    =TEXT(NPV(999,IF(C$6:C$11=$B2,$B$6:$B$11))*10^(COUNTIFS(C$6:C$11,$B2)*3),REPT("000"&CHAR(10),COUNTIFS(C$6:C$11,$B2)))
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Cells that conditionally displays a concatenated list of other cells' contents

    Why would anyone with a version of Excel recent enough to have the built-in TEXTJOIN function use a user-defined function to accomplish the same thing?

  8. #8
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Cells that conditionally displays a concatenated list of other cells' contents

    OP mentioned the TEXTJOIN formula was working, so either they're [incorrect] about that, [incorrect] about the Office version they're actually using, or (gasp!) MSFT's documentation is inaccurate.
    Last edited by 6StringJazzer; 09-25-2020 at 06:08 PM. Reason: Edited at request of member

  9. #9
    Registered User
    Join Date
    04-05-2017
    Location
    Houston, TX
    MS-Off Ver
    2016
    Posts
    57

    Re: Cells that conditionally displays a concatenated list of other cells' contents

    Thanks for the help everyone. I think I have what I need now.

+ 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. VBA to list rows with coloured/conditionally formatted cells
    By jamiem4 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 11-28-2016, 06:27 PM
  2. Replies: 1
    Last Post: 01-20-2016, 08:56 AM
  3. [SOLVED] VBA Clear contents of other cells when certain cell displays certain value
    By D.Lovell in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-23-2015, 12:56 PM
  4. Conditionally combine/write contents from cells
    By CatawbaRiverkeeper in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-22-2014, 04:49 PM
  5. Replies: 9
    Last Post: 09-07-2012, 11:21 AM
  6. Conditionally copy selected cells in rows depending on cell contents.
    By danando in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-11-2011, 08:50 PM
  7. make List of Unshaded cells contents in vertical List
    By Sweetypie in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 07-17-2010, 05:12 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