+ Reply to Thread
Results 1 to 12 of 12

Concatenate Leave Out Blanks Add Carriage Return

  1. #1
    Registered User
    Join Date
    02-03-2013
    Location
    Houston, TX
    MS-Off Ver
    Excel 2013
    Posts
    22

    Concatenate Leave Out Blanks Add Carriage Return

    Hi. I have a spreadsheet and I want to add several cells in a column into another cell. If there are blanks, I want those skipped and if there is text in the cell, I want a carriage return between each cell in the column. Here's an example below.

    Column A
    Apple
    Apple Pie
    Blank
    Banana Bread
    Blank
    Blueberry Muffins


    I want it to look like the below in a singe cell.
    Apple
    Apple Pie
    Banana Bread
    Blueberry Muffins

    Thanks for your help!

  2. #2
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Concatenate Leave Out Blanks Add Carriage Return

    Add this code to a new VBA Module within your workbook:
    Please Login or Register  to view this content.
    Then, if your data is in A1:A6, you can type this into B1: =ConcRange(A1:A6,CHAR(10))
    Just make sure Text Wrap is on, otherwise it won't look right.

    - Moo

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Concatenate Leave Out Blanks Add Carriage Return

    ...or a non VBA solution, with your data starting in A2, in B2
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    copied down to last cell, with the last cell formatted with 'Wrap Text'
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    02-03-2013
    Location
    Houston, TX
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: Concatenate Leave Out Blanks Add Carriage Return

    Thank you both! I really appreciate it. I spent hours trying to find a solution and within an hour, you two solved my problem. Thanks again!

  5. #5
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Concatenate Leave Out Blanks Add Carriage Return

    Glad to help, and thanks for the feedback. It's always appreciated.

    - Moo

  6. #6
    Registered User
    Join Date
    02-03-2013
    Location
    Houston, TX
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: Concatenate Leave Out Blanks Add Carriage Return

    Moo,

    After working with the code you provided, I realized I should have given you a tad bit more data. All my data is in column A, but I want to skip a few rows so when I use your formula, some of the text in the cell is only separated by a space instead of a carriage return. Is there a formula I can insert between your formula to make it have a carriage return instead of a space? My example is below.


    Column A
    Apple
    Apple Pie
    Blank
    Banana Bread
    Blank
    Blueberry Muffins
    SKIP
    SKIP
    SKIP
    Turkey Sandwich
    Ham Sandwich
    Bologna Sandwich
    SKIP
    SKIP
    SKIP
    Cookie
    Ice Cream

    It looks like this in the cell.
    Apple
    Apple Pie
    Banana Bread
    Blueberry Muffins Turkey Sandwich
    Ham Sandwich
    Bologna Sandwich Cookie
    Ice Cream

    I hope that helps.
    Last edited by gawk1980; 02-03-2013 at 06:28 PM.

  7. #7
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Concatenate Leave Out Blanks Add Carriage Return

    I don't know what you mean by SKIP a row... if there are blanks in the range from A1:A17 (based on your new list) it will ignore the blanks. But the formula won't SKIP rows (as in, disregard rows with values).

    See my attached sheet with your latest data included.. seems to work fine.

    - Moo
    Attached Files Attached Files

  8. #8
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Concatenate Leave Out Blanks Add Carriage Return

    I guess if you want to manually skip certain cells, you could do it this way:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    - Moo

  9. #9
    Registered User
    Join Date
    02-03-2013
    Location
    Houston, TX
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: Concatenate Leave Out Blanks Add Carriage Return

    Thanks for replying back so quickly. I should have said I wanted to select a range, so A1:A6 and then A10:A17. So for your example, it would look like:

    Apple
    Apple Pie
    Banana Bread
    Blueberry MuffinsTurkey Sandwich
    Ham Sandwich
    Bologna Sandwich
    Cookie
    Ice Cream

  10. #10
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Concatenate Leave Out Blanks Add Carriage Return

    Quote Originally Posted by Moo the Dog View Post
    I guess if you want to manually skip certain cells, you could do it this way:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    - Moo
    I must have posted this when you were writing a reply.

  11. #11
    Registered User
    Join Date
    02-03-2013
    Location
    Houston, TX
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: Concatenate Leave Out Blanks Add Carriage Return

    You are so fast. That's exactly what I needed! Thank you again!

  12. #12
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Concatenate Leave Out Blanks Add Carriage Return

    You're welcome. Glad to help.

    - Moo

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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