+ Reply to Thread
Results 1 to 8 of 8

concatenate rows of values in a string

  1. #1
    Registered User
    Join Date
    09-19-2008
    Location
    Gloucester, MA
    MS-Off Ver
    Excel 2016
    Posts
    62

    concatenate rows of values in a string

    I need to determine where the 1's are in a column of data and then identify or concatenate their rows in a cell.

    For instance column A looks like the following:

    Col A
    0
    1
    0
    0
    0
    1
    0

    In cell B1 I need to know in string format that the 1's are in rows "2 and 7". This will be part of an error message to alert the user that these rows need fixing.

    Thanks for your help.

  2. #2
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: concatenate rows of values in a string

    Hmmm...Why not 'conditionally format' column A to highlight cells (in red perhaps?!) that carry the value '1'

    http://www.cpearson.com/excel/cformatting.htm
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  3. #3
    Registered User
    Join Date
    09-19-2008
    Location
    Gloucester, MA
    MS-Off Ver
    Excel 2016
    Posts
    62

    Re: concatenate rows of values in a string

    The data is in a sheet that is hidden from the user. I then have a sheet that provides test results of certain data entries on numerous sheets. This will tell them what sheet contains the error.

  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: concatenate rows of values in a string

    Does this mean you want the relative position numbers of the 1's within the data array?

    For example, if the actual range address is A22:A28 the 1's are still located in positions 2 and 7, correct?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    Registered User
    Join Date
    09-19-2008
    Location
    Gloucester, MA
    MS-Off Ver
    Excel 2016
    Posts
    62

    Re: concatenate rows of values in a string

    Yes, that's correct.

  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: concatenate rows of values in a string

    OK, if you want the results to appear in a single cell then you'll need some form of VBA to do this.

    Copy the code below and paste it into a general module.

    Please Login or Register  to view this content.
    Assuming your data is in the range A2:A8, enter this array formula** in B2:

    =SUBSTITUTE(TRIM(aconcat(IF(A2:A8=1," "&ROW(A2:A8)-ROW(A2)+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.

  7. #7
    Registered User
    Join Date
    09-19-2008
    Location
    Gloucester, MA
    MS-Off Ver
    Excel 2016
    Posts
    62

    Re: concatenate rows of values in a string

    This works perfectly! I was able to change it a bit to fit my application. Thanks

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

    Re: concatenate rows of values in a string

    You're welcome. Thanks for the feedback!

+ 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