+ Reply to Thread
Results 1 to 9 of 9

Adjust CHAR(10) function - limit line breaks

  1. #1
    Registered User
    Join Date
    07-17-2020
    Location
    Philadelphia
    MS-Off Ver
    Office 2013
    Posts
    17

    Adjust CHAR(10) function - limit line breaks

    In the calendar view sheet - Cell E9 for example - my objective is to have each vegetable show "Quantity - Vegee - Location" on each line. But the CHAR(10) function is placing every piece of data on its' own line.

    Is there a way to adjust the formula to keep associated data together and only add a line break for the different vegetables?
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,778

    Re: Adjust CHAR(10) function - limit line breaks

    How about
    =SUBSTITUTE(IF(VLOOKUP(E8,'Date Table'!$D$6:$AI$888,32,FALSE)=0," ",VLOOKUP(E8,'Date Table'!$D$6:$AI$888,32,FALSE))," ",CHAR(10),{3,6,9})

    Confirm with Ctrl Shift Enter, rather than just Enter

  3. #3
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Adjust CHAR(10) function - limit line breaks

    Hmm... easiest way to handle it is to change your "Input sheet" O column formula.

    =IF(C4<>"",E4&"-"&C4&"-"&F4&G4&H4,"")

    Copy down. No other change needed.

    Result will look like...
    0.JPG

    If you wanted to preserve single space rather than "-" in the Calendar view.

    You can add additional substitute to your formula in Calendar view.

    =SUBSTITUTE(SUBSTITUTE(IF(VLOOKUP(E8,'Date Table'!$D$6:$AI$888,32,FALSE)=0," ",VLOOKUP(E8,'Date Table'!$D$6:$AI$888,32,FALSE))," ",CHAR(10)),"-"," ")
    "Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something."
    ― Robert A. Heinlein

  4. #4
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,706

    Re: Adjust CHAR(10) function - limit line breaks

    @Fluff13, not sure that would work

    @Pencil+Pen,

    I think you have an issue on your Date Table formula with relative/fixed references etc and, given your version, you could simplify to:

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


    remainder of initial post removed in favour of CK76s approach which is better -- though I'd say the double evaluation becomes superfluous once you apply the SUBSTITUTE:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by XLent; 07-23-2020 at 11:17 AM.

  5. #5
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,778

    Re: Adjust CHAR(10) function - limit line breaks

    @Fluff13, not sure that would work
    It works in 365, but I can't test to see if it also works in 2013.

  6. #6
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,706

    Re: Adjust CHAR(10) function - limit line breaks

    Hi, doesn't work for me w/O365 .. that said, I am on the semi-annual channel (and rely on work for updates) so I still don't have likes of FILTER etc...
    (but, given above, it won't work with earlier versions)

    for reference I was testing the approach with =SUBSTITUTE("appleapple","p","^",{1,3}) but I only get "a^pleapple"

  7. #7
    Registered User
    Join Date
    07-17-2020
    Location
    Philadelphia
    MS-Off Ver
    Office 2013
    Posts
    17

    Re: Adjust CHAR(10) function - limit line breaks

    Thank you all for replying.

    @CK76 - Your method worked. Thank you! I tried to add to your rep again but it won't let me!

  8. #8
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Adjust CHAR(10) function - limit line breaks

    You are welcome and no worries But you may want to consider giving reps to others that contributed.

    FYI - With O365, there are more efficient method. Your AI column formula can be changed to TEXTJOIN(), which has argument to use custom delimiter and ignore blanks. That will significantly simplify downstream manipulation. But for backward compatibility, I tend to avoid these new functions, unless document is for internal use only.

  9. #9
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,778

    Re: Adjust CHAR(10) function - limit line breaks

    Quote Originally Posted by XLent View Post
    for reference I was testing the approach with =SUBSTITUTE("appleapple","p","^",{1,3}) but I only get "a^pleapple"
    I get the same result as you with that formula, although it worked on the OP's file.

    Just another oddity, which is irrelevant here as it obviously wont work for the OP.

+ 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. Adding CHAR(10) to add line breaks causes speech marks to be added
    By Fozzy279 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-13-2020, 12:10 PM
  2. Removing line space in Concatenate and Char(10) function
    By treesieg in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-18-2019, 11:43 AM
  3. NEED HELP WITH LINE BREAK CHAR(10) Function
    By mayur.online in forum Excel General
    Replies: 1
    Last Post: 03-05-2018, 10:44 AM
  4. Formulas and Line Breaks - inserting mid-string & removing excess breaks
    By MattDay2u in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 10-24-2017, 09:54 AM
  5. Any way around the 255 char string limit?
    By scottc_00 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-15-2016, 10:18 AM
  6. Replies: 8
    Last Post: 03-10-2015, 01:05 AM
  7. [SOLVED] Unable to get cell count when using line breaks char(10)
    By Ronoh in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-01-2014, 01:10 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