+ Reply to Thread
Results 1 to 5 of 5

Insert a line break (CHAR(10)) after every 42 characters

  1. #1
    Registered User
    Join Date
    06-21-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    1

    Insert a line break (CHAR(10)) after every 42 characters

    Hi All,

    I need a formula to insert a line break after every 42 characters in a cell , example if there is 266 characters in a cell there should be 6(266/42)line breaks.

    =REPLACE(REPLACE(A1,42,0,CHAR(10)),84,0,CHAR(10))

    I tried this but i am not sure how to get the start num to change to 126,168 and so on

    Any help is highly appreciated

    Thanks
    Last edited by Rajkiran557; 06-21-2014 at 08:17 PM.

  2. #2
    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: Insert a line break (CHAR(10)) after every 42 characters

    Hi,

    Maybe this UDF will suffice and be simpler than a formula

    Please Login or Register  to view this content.
    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.

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Insert a line break (CHAR(10)) after every 42 characters

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    05-10-2013
    Location
    Pomáz, Hungary
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Insert a line break (CHAR(10)) after every 42 characters

    Not too elegant but seems to work:


    =MID(A1,1,42)&CHAR(10)&MID(A1,42,42)&CHAR(10)&MID(A1,84,42)&CHAR(10)&MID(A1,126,42)&CHAR(10)&MID(A1,168,42)&CHAR(10)&MID(A1,210,42)&CHAR(10)
    Last edited by István Hirsch; 06-22-2014 at 05:12 AM.

  5. #5
    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: Insert a line break (CHAR(10)) after every 42 characters

    Quote Originally Posted by István Hirsch View Post
    Not too elegant but seems to work:


    =MID(A1,1,42)&CHAR(10)&MID(A1,42,42)&CHAR(10)&MID(A1,84,42)&CHAR(10)&MID(A1,126,42)&CHAR(10)&MID(A1,168,42)&CHAR(10)&MID(A1,210,42)&CHAR(10)
    Hi,

    That will of course work for up to 6 lines but the OP doesn't say whether the string varies in length. I took the reference to 'and so on' to mean 266 was just one example and there might be others of longer (or indeed shorter) lengths.
    Maybe the OP will comment.

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

    Re: Insert a line break (CHAR(10)) after every 42 characters

    This is what I offered at the cross-post (I was the only one who responded there before the cross-post notice was put up at the MrExcel forum)...

    I am not sure you will be able to do this with a formula, but there is a VBA coded method available, see my mini-blog article here...

    http://www.excelfox.com/forum/f22/wr...-per-line-355/

+ 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. Replies: 1
    Last Post: 03-16-2013, 03:58 PM
  2. Automatic Line Break at X number of characters
    By duyane in forum Excel General
    Replies: 3
    Last Post: 07-17-2012, 02:12 AM
  3. Replies: 5
    Last Post: 10-19-2011, 12:27 PM
  4. How to break up a cell with 3 embedded (new line characters) value
    By Phil in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-23-2005, 07:05 PM
  5. insert &char(10) after 100 characters
    By murphyz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-23-2005, 05:57 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