+ Reply to Thread
Results 1 to 7 of 7

Help with a Formula to Concatenate Cell Text in a New Line and Skipping Blanks

  1. #1
    Forum Contributor
    Join Date
    03-14-2013
    Location
    Maryland, USA
    MS-Off Ver
    Excel 365
    Posts
    105

    Help with a Formula to Concatenate Cell Text in a New Line and Skipping Blanks

    Hello Everybody,

    I have a report which has 10 cells for comments (Text), and they are no contiguous also not all of them will have text.
    I want to be able to concatenate them in the way that each comment is one separate line and skip the blank comments.
    I found these two formulas that partially works:

    1-This formula concatenate the cells contents but do not skip the blanks.

    =E.Data!S2&CHAR(10)&E.Data!Y2&CHAR(10)&E.Data!AK2&CHAR(10)&E.Data!AV2&CHAR(10)&E.Data!BB2&CHAR(10)&E.Data!BJ2&CHAR(10)&E.Data!BX2&CHAR(10)&E.Data!CM2&CHAR(10)&E.Data!DB2

    2- and this one skip the blanks but do no added in a new line.

    =SUBSTITUTE(TRIM(E.Data!S3&" "&E.Data!Y3&" "&E.Data!AK3&" "&E.Data!AV3&" "&E.Data!BB3&" "&E.Data!BJ3&" "&E.Data!BX3&" "&E.Data!CM3&" "&E.Data!DB3)," ",", ")

    I've been trying to modify these formulas without sucess. and not be able to find any similar case.

    Can someone help me with this one or point me to the right direction?

    I really appreciate any help.

    Respectfully,

    Alex

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,760

    Re: Help with a Formula to Concatenate Cell Text in a New Line and Skipping Blanks

    A little unwieldy but I believe this will do what you want. Another option that would simplify the formula would be a macro or user-defined function in VBA.

    =IF(E.Data!S2="","",E.Data!S2&CHAR(10)) & IF(E.Data!Y2="","",E.Data!Y2&CHAR(10)) & IF(E.Data!AK2="","",E.Data!AK2&CHAR(10)) & IF(E.Data!AV2="","",E.Data!AV2&CHAR(10)) & IF(E.Data!BB2="","",E.Data!BB2&CHAR(10)) & IF(E.Data!BJ2="","",E.Data!BJ2&CHAR(10)) & IF(E.Data!BX2="","",E.Data!BX2&CHAR(10)) & IF(E.Data!CM2="","",E.Data!CM2&CHAR(10)) & E.Data!DB2

    BTW your formula has 9 cells, not 10.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    03-14-2013
    Location
    Maryland, USA
    MS-Off Ver
    Excel 365
    Posts
    105

    Re: Help with a Formula to Concatenate Cell Text in a New Line and Skipping Blanks

    6StringJazzer,

    Thank you for your fast response, I really appreciate it, you are right is only 9 cells, my bad.
    When using your formula it does the same as my second formula which skips the blanks but do not add the next cell content in a new line.
    I might not explain myself clear, I have attached a sample to illustrate you what I want to get.

    In sheet E. Data I have a table which is populated using an user form and have columns with Comments1 and Comments 2, not all the entries will have comments but when the have I want to concatenate them in sheet B, Comments1 will be in column N and Comments 2 will be in column O.

    As you can see in N4 I place your formula, which skip the blanks but is only one string.
    In N5 is my second formula which does the same.
    In O4 is my first formula which add the next comment in a new line but don't skip the blanks and
    In O5 is how i want it to be concatenated.

    I have no found a macro that could do this, but the formula I'm looking for is to be inserted in a macro, I'm no familiar with the UDF.

    Hope you can help me with this problem.

    Thanks again for your time

    Respectfully,

    Alex
    Attached Files Attached Files

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,760

    Re: Help with a Formula to Concatenate Cell Text in a New Line and Skipping Blanks

    Cells N4, N5, O4, O5 are all empty.

    I put my formula in N2:N5 and it worked perfectly.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    03-14-2013
    Location
    Maryland, USA
    MS-Off Ver
    Excel 365
    Posts
    105

    Re: Help with a Formula to Concatenate Cell Text in a New Line and Skipping Blanks

    6StringJazzer,

    Ok, getting close, the formula is going on sheet B which is were you can see my previous explanation, you are right the formula work perfectly, the error was mine because I need to wrap the text in cell.

    So now when I put the formula in the following piece of macro it give me the following result:

    FALSEFALSEFALSEFALSEFALSEFALSEFALSEFALSE9-Outcomes:

    and this is the macro:
    Please Login or Register  to view this content.
    I really don't know what happen

    Could you take a look at this, maybe using a macro will be better approach?

    Thanks for yor time.

    Respectfully,

    Alex
    Attached Files Attached Files

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,760

    Re: Help with a Formula to Concatenate Cell Text in a New Line and Skipping Blanks

    In VBA code, if you have a quote within a quoted string, you must repeat the quote twice.
    Please Login or Register  to view this content.
    etc.

  7. #7
    Forum Contributor
    Join Date
    03-14-2013
    Location
    Maryland, USA
    MS-Off Ver
    Excel 365
    Posts
    105

    Re: Help with a Formula to Concatenate Cell Text in a New Line and Skipping Blanks

    6StringJazzer,

    Perfect!!!,

    You save me a lot of time, I really appreciate your time and patient with me and this work.

    Thanks again.

    Respectfully,

    Alex

+ 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. [SOLVED] Concatenate text with a line break
    By AnnieMcken in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-22-2014, 12:44 PM
  2. Replies: 7
    Last Post: 05-28-2014, 01:20 AM
  3. Replies: 1
    Last Post: 05-21-2014, 04:30 PM
  4. Line chart, skipping 0 or text entries
    By Lithium78 in forum Excel General
    Replies: 4
    Last Post: 04-23-2010, 01:27 PM
  5. [SOLVED] Skipping a cell and moving on to the next, with no blanks in betwe
    By SteveC in forum Excel General
    Replies: 8
    Last Post: 05-18-2006, 04:40 AM
  6. [SOLVED] Subtraction formula for consecutive cells in a column, skipping blanks
    By elton@rogers.com in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-15-2005, 08:05 PM
  7. Replies: 0
    Last Post: 02-22-2005, 12:06 AM

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