+ Reply to Thread
Results 1 to 14 of 14

Take CHAR(10) out automatically when redundant

  1. #1
    Registered User
    Join Date
    08-22-2019
    Location
    Edmonton, Canada
    MS-Off Ver
    Version 1809
    Posts
    18

    Take CHAR(10) out automatically when redundant

    In this formula, I tried using TRIM but apparently it doesn't acknowledge CHAR(10), but only redundant spaces. If I don't have the referenced filled out, it will still enter a line break. How do I go about eliminating CHAR(10) if the cell before it is empty?

    =TRIM(CONCAT('1'!A47,CHAR(10),'1'!B54,CHAR(10),'1'!B56,CHAR(10),'1'!B57,CHAR(10),'1'!B58,CHAR(10),'1'!B59,CHAR(10),'1'!B60,CHAR(10),'1'!B61,CHAR(10),'1'!B62,CHAR(10),'1'!B63,CHAR(10),'1'!B64,CHAR(10),'1'!B65,CHAR(10),'1'!B66,CHAR(10),'1'!B67,CHAR(10),'1'!B68,CHAR(10),'1'!B69))

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Take CHAR(10) out automatically when redundant

    Have you tried using the CLEAN function?

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,726

    Re: Take CHAR(10) out automatically when redundant

    If one or more of your referenced cells are empty, then you will end up with two line feed characters together, so you could put a SUBSTITUTE function around your formula to change two CHAR(10)'s with one.

    Hope this helps.

    Pete

  4. #4
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Take CHAR(10) out automatically when redundant

    Quote Originally Posted by burrjc View Post
    =TRIM(CONCAT('1'!A47,CHAR(10),'1'!B54,CHAR(10),'1'!B56,CHAR(10),'1'!B57,CHAR(10),'1'!B58,CHAR(10),'1'!B59,CHAR(10),'1'!B60,CHAR(10),'1'!B61,CHAR(10),'1'!B62,CHAR(10),'1'!B63,CHAR(10),'1'!B64,CHAR(10),'1'!B65,CHAR(10),'1'!B66,CHAR(10),'1'!B67,CHAR(10),'1'!B68,CHAR(10),'1'!B69))
    This doesn't answer your question, but online documentation seems to suggest (I don't have the CONCAT function in my version of Excel, so i cannot test it) that you can simplify your above formula like this...

    =TRIM(CONCAT('1'!A47,CHAR(10),'1'!B54,CHAR(10),'1'!B56:B69))

    Now, assuming the above is correct, you should be able to do what you want with this untested (obviously given the above) formula...

    =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(CONCAT('1'!A47,CHAR(10),'1'!B54,CHAR(10),'1'!B56),REPT(CHAR(10),13),CHAR(10)),REPT(CHAR(10),5),CHAR(10)),REPT(CHAR(10),3),CHAR(10)),REPT(CHAR(10),3),CHAR(10)),REPT(CHAR(10),2),CHAR(10))

  5. #5
    Registered User
    Join Date
    08-22-2019
    Location
    Edmonton, Canada
    MS-Off Ver
    Version 1809
    Posts
    18

    Re: Take CHAR(10) out automatically when redundant

    The CLEAN function takes ALL of the CHAR(10) out and turns it into a jumble of words.

  6. #6
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Take CHAR(10) out automatically when redundant

    Quote Originally Posted by burrjc View Post
    The CLEAN function takes ALL of the CHAR(10) out and turns it into a jumble of words.
    Did you see the formula I posted in Message #4?

  7. #7
    Registered User
    Join Date
    08-22-2019
    Location
    Edmonton, Canada
    MS-Off Ver
    Version 1809
    Posts
    18

    Re: Take CHAR(10) out automatically when redundant

    Unfortunately =TRIM(CONCAT('1'!A47,CHAR(10),'1'!B54,CHAR(10),'1'!B56:B69)) doesn't work

  8. #8
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Take CHAR(10) out automatically when redundant

    Quote Originally Posted by burrjc View Post
    Unfortunately =TRIM(CONCAT('1'!A47,CHAR(10),'1'!B54,CHAR(10),'1'!B56:B69)) doesn't work
    Hmm, the documentation seems to suggest it should. In order to help someone with your version of Excel who may come along later, please describe "doesn't work" (tell us exactly what happens including what if any errors occur).

    By the way, given that you do not seem to have a solution yet, why did you mark this thread as SOLVED?
    Last edited by Rick Rothstein; 10-07-2019 at 07:12 PM.

  9. #9
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,726

    Re: Take CHAR(10) out automatically when redundant

    Did you try my suggestion in Post #3, i.e.:

    =SUBSTITUTE(TRIM(CONCAT('1'!A47,CHAR(10),'1'!B54,CHAR(10),'1'!B56,CHAR(10),'1'!B57,CHAR(10),'1'!B58,CHAR(10),'1'!B59,CHAR(10),'1'!B60,CHAR(10),'1'!B61,CHAR(10),'1'!B62,CHAR(10),'1'!B63,CHAR(10),'1'!B64,CHAR(10),'1'!B65,CHAR(10),'1'!B66,CHAR(10),'1'!B67,CHAR(10),'1'!B68,CHAR(10),'1'!B69)),CHAR(10)&CHAR(10),CHAR(10))

    Hope this helps.

    Pete

  10. #10
    Registered User
    Join Date
    08-22-2019
    Location
    Edmonton, Canada
    MS-Off Ver
    Version 1809
    Posts
    18

    Re: Take CHAR(10) out automatically when redundant

    Quote Originally Posted by Pete_UK View Post
    Did you try my suggestion in Post #3, i.e.:

    =SUBSTITUTE(TRIM(CONCAT('1'!A47,CHAR(10),'1'!B54,CHAR(10),'1'!B56,CHAR(10),'1'!B57,CHAR(10),'1'!B58,CHAR(10),'1'!B59,CHAR(10),'1'!B60,CHAR(10),'1'!B61,CHAR(10),'1'!B62,CHAR(10),'1'!B63,CHAR(10),'1'!B64,CHAR(10),'1'!B65,CHAR(10),'1'!B66,CHAR(10),'1'!B67,CHAR(10),'1'!B68,CHAR(10),'1'!B69)),CHAR(10)&CHAR(10),CHAR(10))

    Hope this helps.

    Pete
    Yes, this is better but there's still 1 dead space between a couple things, which is weird. Prior to SUBSTITUTE, there were 5 line breaks, and now there are 3.

    =SUBSTITUTE(TRIM(CONCAT('Pricing 1'!A17,CHAR(10),'Pricing 1'!B24,CHAR(10),'Pricing 1'!B26,CHAR(10),'Pricing 1'!B27,CHAR(10),'Pricing 1'!B28,CHAR(10),'Pricing 1'!B29,CHAR(10),'Pricing 1'!B30,CHAR(10),'Pricing 1'!B31,CHAR(10),'Pricing 1'!B32,CHAR(10),'Pricing 1'!B33,CHAR(10),'Pricing 1'!B34,CHAR(10),'Pricing 1'!B35,CHAR(10),'Pricing 1'!B36,CHAR(10),'Pricing 1'!B37,CHAR(10),'Pricing 1'!B38)),CHAR(10)&CHAR(10),CHAR(10))

  11. #11
    Registered User
    Join Date
    08-22-2019
    Location
    Edmonton, Canada
    MS-Off Ver
    Version 1809
    Posts
    18

    Re: Take CHAR(10) out automatically when redundant

    Quote Originally Posted by Rick Rothstein View Post

    By the way, given that you do not seem to have a solution yet, why did you mark this thread as SOLVED?
    That is also what I'm wondering.... My ADHD has been insane the past couple weeks, every day is a surprise to melately, lol.

  12. #12
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Take CHAR(10) out automatically when redundant

    With TEXTJOIN:

    Please Login or Register  to view this content.
    Without:

    Please Login or Register  to view this content.
    This one needs to be entered with Ctrl+Shift+Enter to create an array formula.

    WBD
    Office 365 on Windows 11, looking for rep!

  13. #13
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,726

    Re: Take CHAR(10) out automatically when redundant

    Quote Originally Posted by burrjc View Post
    … Yes, this is better but there's still 1 dead space between a couple things ...
    Well then presumably you had 3 CHAR(10)s together - the first 2 would have been replaced by a single one, but you would still have the other one which will give you a double line-break. You could have another SUBSTITUTE around the one I gave you, replacing 2 char(10)'s with a single one, but then if you had 5 char(10)'s together you would still end up with a double one. You could avoid it completely by changing your formula like this:

    =SUBSTITUTE(SUBSTITUTE(IF('1'!A47="","",'1'!A47&CHAR(10)) & IF('1'!B54="","",'1'!B54&CHAR(10)) & IF('1'!B56="","",'1'!B56&CHAR(10)) & IF('1'!B57="","",'1'!B57&CHAR(10)) & IF('1'!B58="","",'1'!B58&CHAR(10)) & IF('1'!B59="","",'1'!B59&CHAR(10)) & IF('1'!B60="","",'1'!B60&CHAR(10)) & IF('1'!B61="","",'1'!B61&CHAR(10)) & IF('1'!B62="","",'1'!B62&CHAR(10)) & IF('1'!B63="","",'1'!B63&CHAR(10)) & IF('1'!B64="","",'1'!B64&CHAR(10)) & IF('1'!B65="","",'1'!B65&CHAR(10)) & IF('1'!B66="","",'1'!B66&CHAR(10)) & IF('1'!B67="","",'1'!B67&CHAR(10)) & IF('1'!B68="","",'1'!B68&CHAR(10)) & IF('1'!B69="","",'1'!B69&CHAR(10)) & "$$",CHAR(10)&"$$",""),"$$","")

    so the line feed character only appears if a cell contains something. A special character "$$" is added onto the end, so the final CHAR(10) can be removed, and if the cells are all blank (so no CHAR(10)'s appear anywhere), then a final SUBSTITUTE will remove the remaining "$$".

    I can't try out solutions with TEXTJOIN or CONCAT in my version of Excel.

    Hope this helps.

    Pete

  14. #14
    Registered User
    Join Date
    08-22-2019
    Location
    Edmonton, Canada
    MS-Off Ver
    Version 1809
    Posts
    18

    Re: Take CHAR(10) out automatically when redundant

    Quote Originally Posted by WideBoyDixon View Post
    With TEXTJOIN:

    Please Login or Register  to view this content.

    WBD

    TEXTJOIN WORKS!!! Thanks alot everyone. This seems to be the easiest.

+ 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] How to combine FINDing CHAR(42) and CHAR(47) in 1 formula
    By RJK in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 07-05-2015, 02:54 AM
  2. Replies: 12
    Last Post: 04-08-2014, 08:12 PM
  3. Conditional Formatting - Change Text to CHAR(252) Automatically
    By nkitchen31 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-27-2013, 10:06 PM
  4. Macro for automatically identify redundant data and remove it
    By pyol17 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-23-2012, 04:48 AM
  5. Add Quantity of Redundant Rows, then Delete Redundant Rows
    By alexwgordon in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-04-2012, 12:12 AM
  6. Changing a single Char in a string to another ASCII char
    By goofy78270 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-15-2007, 09:45 AM
  7. Replies: 6
    Last Post: 03-10-2006, 01:15 PM

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