Closed Thread
Results 1 to 14 of 14

Remove CHAR(10) blank from CONCATENATE formula

  1. #1
    Registered User
    Join Date
    03-29-2013
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    78

    Remove CHAR(10) blank from CONCATENATE formula

    Hi Guys,

    I am trying to remove the blanks from a CONCATENATE formula that uses CHAR(10). The CONCATENATE formula references a range of cells and puts a CHAR(10) to make a new row after each referenced cell. However some of these cells may be blank if the cell THEY reference is 0. But the CONCATENATE formula still puts in the CHAR(10) line return resulting in a cell with lots of gaps and therefore messy!!

    I'd rather not get into VBA as that's a whole can of worms I'm not sure I want to get into! A formula solution would be great!

    See file attached.

    Thanks very much.

    Remove gaps from CONCATENATE.xlsx

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

    Re: Remove CHAR(10) blank from CONCATENATE formula

    Change formula in F2 to
    =IF(A2="","",A2&" No. "&B2&CHAR(10))

    Copy down

    In F24
    =LEFT(CONCATENATE(F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,F14,F15,F16,F17,F18,F19,F20,F21,F22),LEN(CONCATENATE(F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,F14,F15,F16,F17,F18,F19,F20,F21,F22))-1)
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  3. #3
    Forum Contributor
    Join Date
    01-30-2013
    Location
    Wales
    MS-Off Ver
    Excel 2013
    Posts
    231

    Re: Remove CHAR(10) blank from CONCATENATE formula

    Hi

    Try replacing the Char(10) text with if(F2<>"",Char(10),"") Obviously change the F2 to the relevant cell in column F.

    Chris

  4. #4
    Registered User
    Join Date
    03-29-2013
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    78

    Re: Remove CHAR(10) blank from CONCATENATE formula

    Thanks Ace_XL

    That works great however in another spread sheet I am trying to use this on, the values in the qty column A are actually derived from =SUMIF formulas. Your suggested formulas seam not to work with this.

    Any ideas?

    Thanks.


    Quote Originally Posted by Ace_XL View Post
    Change formula in F2 to
    =IF(A2="","",A2&" No. "&B2&CHAR(10))

    Copy down

    In F24
    =LEFT(CONCATENATE(F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,F14,F15,F16,F17,F18,F19,F20,F21,F22),LEN(CONCATENATE(F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,F14,F15,F16,F17,F18,F19,F20,F21,F22))-1)

  5. #5
    Registered User
    Join Date
    03-29-2013
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    78

    Re: Remove CHAR(10) blank from CONCATENATE formula

    Hi Chris 53,

    Thanks for that. Sorry to sound daft but where would I put the if(F2<>"",Char(10),"") ?

    Thanks.

  6. #6
    Forum Contributor
    Join Date
    01-30-2013
    Location
    Wales
    MS-Off Ver
    Excel 2013
    Posts
    231

    Re: Remove CHAR(10) blank from CONCATENATE formula

    In F24 your formula starts with =CONCATENATE(F2,CHAR(10),F3,CHAR(10),F4,CHAR(10),F5,CHAR(10),F6,CHAR(10),

    Change all the ,CHAR(10), to if(F2<>"",Char(10),"")

    Chris

  7. #7
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,290

    Re: Remove CHAR(10) blank from CONCATENATE formula

    =CONCATENATE(IF(F2="","",F2),IF(F3="","",CHAR(10)&F3),IF(F4="","",CHAR(10)&F4))

    Try this one

    Or:
    =CONCATENATE(IF(F2="","",F2&CHAR(10)),IF(F3="","",F3&CHAR(10)),IF(F4="","",F4&CHAR(10)))
    Last edited by popipipo; 08-21-2013 at 06:21 AM.
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

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

    Re: Remove CHAR(10) blank from CONCATENATE formula

    f2 down =IF(A2=0," ",A2&"^No.^"&SUBSTITUTE(B2," ","^")&" ")
    then i24
    =SUBSTITUTE(SUBSTITUTE(TRIM(F2&F3&F4&F5&F6&F7&F8&F9&F10&F11&F12&F13&F14&F15&F16&F17&F18&F19&F20&F21&F22)," ",CHAR(10)),"^"," ")
    "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

  9. #9
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Remove CHAR(10) blank from CONCATENATE formula

    You could save a bit of typing by using this with Ace_XLs' solution
    In F24
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  10. #10
    Registered User
    Join Date
    03-29-2013
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    78

    Re: Remove CHAR(10) blank from CONCATENATE formula

    Thanks guys. Got it working as I would like (using martindwilson's solution).

    Final query to make it perfect!!: if I have 2 digit values after a single digit values in F24, it looks like this:

    5 No. CH - 10
    4 No. SO - 10
    19 No. ST-13
    4 No. ST-12 - TRAY
    6 No. Scatter Cushion


    Any way to get all the 'No.' to line up.

    No matter if not.

    Thanks again.

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

    Re: Remove CHAR(10) blank from CONCATENATE formula

    well it would be easiest to pad the number with 0 so 1 becomes 01 and 19 remains 19
    =IF(A2=0," ",TEXT(A2,"00")&"^No.^"&SUBSTITUTE(B2," ","^")&" ")
    that would give
    01 No. CH - 10
    03 No. CH - 09
    06 No. OT - 12
    19 No. ST-12 - TRAY

  12. #12
    Registered User
    Join Date
    02-05-2014
    Location
    kuala lumpur, malayis
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Remove CHAR(10) blank from CONCATENATE formula

    Hi,
    I have similar issue with Olly-7, but your formula does not work for me, it does not move the next text to the next line and when it is emply I still see a blank row. and I am concatenating two different sheet. Can you help

  13. #13
    Registered User
    Join Date
    02-05-2014
    Location
    kuala lumpur, malayis
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Remove CHAR(10) blank from CONCATENATE formula

    Quote Originally Posted by martindwilson View Post
    f2 down =IF(A2=0," ",A2&"^No.^"&SUBSTITUTE(B2," ","^")&" ")
    then i24
    =SUBSTITUTE(SUBSTITUTE(TRIM(F2&F3&F4&F5&F6&F7&F8&F9&F10&F11&F12&F13&F14&F15&F16&F17&F18&F19&F20&F21&F22)," ",CHAR(10)),"^"," ")

    Hi, the formula did not work for me. I am trying to concatenate two rows in different sheets into 2 separate lines, and if cells is blank there is still an emty row showing. Can you help?

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,460

    Re: Remove CHAR(10) blank from CONCATENATE formula

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. CHAR(10) not being recognized when using the concatenate function
    By AKM1 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-15-2013, 10:14 AM
  2. how to remove char in cell with conditional
    By vumian in forum Excel General
    Replies: 4
    Last Post: 08-28-2010, 03:48 AM
  3. Char length and remove commas
    By Genkster in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-01-2009, 07:10 PM
  4. [SOLVED] Create a formula to remove text to the left of specified char?
    By TheLazer in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-18-2005, 07:06 AM
  5. [SOLVED] How do I remove Char(160) from a cell?
    By Dave in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-03-2005, 11: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