+ Reply to Thread
Results 1 to 7 of 7

Concatenate IF cell is not empty

  1. #1
    Registered User
    Join Date
    03-06-2013
    Location
    Cumbria
    MS-Off Ver
    Excel 2007
    Posts
    4

    Concatenate IF cell is not empty

    Hi,

    Hoping someone can help me, I have been sent a very large file of product data from one of my suppliers, They sent all of the details in separate fields (for example, colour, height, width, depth, material etc)

    I have processed all these columns to appear how I want them, but now need to join them together so they can all be added to my main description. I want each one to be on a new line when it's displayed on my website, so I'll be adding a <br /> tag (break tag) after each item. This I can do no problem.

    This would all be fine, if all the columns contained data, but a lot of the time the columns do not contain data (eg. I have a column for "knife length" but not all of my products are knives, so not all of them require this information"

    for example, I have something like:

    SKU | Colour | height | width | depth | material
    ABC | blue | 50mm | 10mm | 60mm |
    BCD | | 80mm | 75mm | 30mm | wood
    CDE | red | | | | plastic

    I could use something like :

    =CONCATENATE($A2, " <br /> ", CHAR(10),$B2, " <br /> ", CHAR(10),$C2, " <br /> ", CHAR(10),)

    This however means writing a piece of code for each cell I want to join, My cells go from range "O2" to "DW2", I don't fancy writing that for every single column!!
    Also, it means that If I have some empty fields, it will still add a break tag, this will look very odd on my site.

    I really need a way of writing into the function "include if cell contains data" for each cell. If it doesn't contain anything, skip it and move to the next.
    (the char(10) in this just gives me a line break in excel so I can see what it'll look like when it's exported)

    Any help would be greatly appreciated.

    Thanks!

    Chris

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Concatenate IF cell is not empty

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    but if stuff in cells have spaces in them this wont work
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    03-06-2013
    Location
    Cumbria
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Concatenate IF cell is not empty

    Thanks, but a lot of the stuff is full sentences, so they do have spaces in them

  4. #4
    Valued Forum Contributor adyteo's Avatar
    Join Date
    01-10-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2010
    Posts
    540

    Re: Concatenate IF cell is not empty

    to solve one of your problem (the second part) is this:
    Please Login or Register  to view this content.
    now, for you to avoid including in the formula your hundred columns, you would probably need a macro.

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Concatenate IF cell is not empty

    well unless someone writes a udf for you
    what i'd do would be to select my range and find replace space with ^
    then use the function
    once done id copy /paste special/ values to another sheet
    then find ^ replace with space

  6. #6
    Registered User
    Join Date
    03-06-2013
    Location
    Cumbria
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Concatenate IF cell is not empty

    Martin,

    I never thought of that!

    Replaced all the spaces with a ^, then used your code and it looks to have done exactly what I wanted it to do!

    Thank you!

  7. #7
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Concatenate IF cell is not empty

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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 with Auto Numbering and Eliminate the Empty Value cell(Cells contains Formula)
    By KSQUARE2K6 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-06-2013, 01:21 PM
  2. MACRO to empty a range of cells based on whether specified cell is empty
    By TBJV in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-01-2013, 10:35 PM
  3. Macro to concatenate cells in a range that skips empty columns
    By _lm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-17-2011, 03:53 PM
  4. Replies: 2
    Last Post: 01-06-2011, 11:27 AM
  5. Excel 2007 : Concatenate Next Non-Empty Cell in a Column
    By paulrockliffe in forum Excel General
    Replies: 15
    Last Post: 03-30-2010, 12:04 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