+ Reply to Thread
Results 1 to 30 of 30

Long text to break in parts, lines

  1. #1
    Registered User
    Join Date
    12-04-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 365
    Posts
    55

    Long text to break in parts, lines

    I have a data with millions of rows with Long text. but to include them from our excel to the current software, the acceptance is any number of lines, but each line not to exceed 70 characters.

    Pls provide any formula to convert a long line to paragraph in separate lines.

    Example - take the above lines, i need the output as below:

    I have a data with millions of rows with Long text.
    but to include them from our excel to the current software, the acceptance
    is any number of lines, but each line not to exceed 70 characters.

    Pls advise

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Long text to break in parts, lines

    One way:

    =MID($A1,1+70*(COLUMNS($B1:B1)-1),70)

    copied across.
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Registered User
    Join Date
    12-04-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 365
    Posts
    55

    Re: Long text to break in parts, lines

    Thanks Glenn,

    But
    1. The full work is broken in column "them" the in B and m in C, cant we have check for full words, i mean if including "them exceeds 70" then we can cut the sentence before the word "them"

    2. Also the final output i want in one cell, is it possible too.

    Once again thanks, and awaiting your reply soonest.

    Regards
    Pankaj

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Long text to break in parts, lines

    You didn't mention EITHER of those requirements in your first post, did you?

    I doubt if you will get a formula to do that. if you are still using Excel 2003 and 2007, I do not think you can use Power Query, so you will need VBA. Is that allowed for you? If so, I will move the thread.

  5. #5
    Registered User
    Join Date
    12-04-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 365
    Posts
    55

    Re: Long text to break in parts, lines

    Sorry for not posting in 1st post, i assumed you understood it as truncating after possible word or full stop at 70 of just before 70.

    I am using Excel 2016.
    I u need to move and u think can get solutions pls do move the thread,
    Because i need the solution on this it is too irritating to check one by one. There has to be something in Excel.

    Pankaj

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Long text to break in parts, lines

    Alas, my crystal ball does not tell me about things that are NOT present in a description. I will leave it here for a while, as PowerQuery might work for you. I'm not very familiar with it, but others are...

    Please update the Excel version on your profile, which is very out of date.

  7. #7
    Valued Forum Contributor
    Join Date
    09-30-2018
    Location
    Vlaams Brabant Belgium
    MS-Off Ver
    365
    Posts
    456

    Re: Long text to break in parts, lines

    Here is a start

    Please Login or Register  to view this content.
    Please be as complete as possible in your asking so it may save use all the time to rework the solution because you didn't give all the requirements. If you have a layout in mind please work it out first so we can adapt our solution to it. Thanks.
    If you have been helped, maybe you could click the *

  8. #8
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Long text to break in parts, lines

    Playing with Formula solutions, how many characters are you expecting in your strings? Less than 254?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  9. #9
    Registered User
    Join Date
    12-04-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 365
    Posts
    55
    No the text is more than 500.

    Quote Originally Posted by ChemistB View Post
    Playing with Formula solutions, how many characters are you expecting in your strings? Less than 254?

  10. #10
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,817

    Re: Long text to break in parts, lines

    Please let us know whether or not Joske920's code does what you want so that we don't spend time working on an issue that has already been resolved.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  11. #11
    Registered User
    Join Date
    12-04-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 365
    Posts
    55

    Re: Long text to break in parts, lines

    Sorry for late reply!

    64 characters in one line and 1900 total in one cell, that what my system allows.

  12. #12
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,673

    Re: Long text to break in parts, lines

    Please Login or Register  to view this content.
    Length is 64 as per your LAST post (not 70))

    with data in A1 put this in B1

    =Char64(A1)

    Cell "formatted" as "Wrap text"

    OR

    Please Login or Register  to view this content.
    run the above macro which "loop" through all cells in column A (A1 down)
    Last edited by JohnTopley; 06-16-2021 at 08:21 AM.

  13. #13
    Registered User
    Join Date
    12-04-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 365
    Posts
    55

    Re: Long text to break in parts, lines

    I TRIED IN 1 SHEET, I HAVE ATTACHED SAME SAMPLE TEXT IN A1, could u pls update the formula in this sheet and revert.
    Attached Files Attached Files

  14. #14
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,673

    Re: Long text to break in parts, lines

    Your data has control characters CRLF) which the VBA (currently) does not handle. Are ALL the scripts in this format?

    Please Login or Register  to view this content.
    Updated code.
    Attached Files Attached Files
    Last edited by JohnTopley; 06-16-2021 at 12:32 PM.

  15. #15
    Registered User
    Join Date
    12-04-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 365
    Posts
    55

    Re: Long text to break in parts, lines

    THATS Perfect andwhat i wanted excatly.

    Thanks John Topley..

  16. #16
    Registered User
    Join Date
    12-04-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 365
    Posts
    55

    Re: Long text to break in parts, lines

    Quote Originally Posted by pmbhome View Post
    thats perfect andwhat i wanted excatly.

    Thanks john topley..
    i tried to drag the formula in a1, a2,a3........that doesnt work
    any additonal changes to be made somewhere ?

  17. #17
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,673

    Re: Long text to break in parts, lines

    =char64(A1)

    and drag down works.

  18. #18
    Registered User
    Join Date
    12-04-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 365
    Posts
    55

    Re: Long text to break in parts, lines

    NO I TRIED,

    attached ur file,it shows error !!
    Attached Files Attached Files

  19. #19
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,673

    Re: Long text to break in parts, lines

    It worked for me!
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    12-04-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 365
    Posts
    55

    Re: Long text to break in parts, lines

    well i have multiple excel version, maybe that may be cause.

  21. #21
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,673

    Re: Long text to break in parts, lines

    No ... VBA is independent of Excel version so it should work: I have never any situation where VBA did not run on later versions (than my "old" version) of Excel.

    What error(s) do you get?
    Last edited by JohnTopley; 06-16-2021 at 03:16 PM.

  22. #22
    Registered User
    Join Date
    12-04-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 365
    Posts
    55

    Re: Long text to break in parts, lines

    When i drag, i get #Name? in the fields

  23. #23
    Registered User
    Join Date
    12-04-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 365
    Posts
    55

    Re: Long text to break in parts, lines

    Quote Originally Posted by pmbhome View Post
    When i drag, i get #Name? in the fields
    i GOT IT MACROS WHEN ENABLED ITS OK,
    BUT I CHANGE THE FUNCTION NAME TO MY OWN (LT64), IT GIVES #REF! IN THE CELL

    Also when i tried on actual file it adds a space before the start of each new lines which is not required. (attached sample)

    I am not so good in excel but tried to make changes in the code but cannot rename it and remove spaces.
    Attached Files Attached Files
    Last edited by pmbhome; 06-17-2021 at 12:16 AM. Reason: attach sample

  24. #24
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,673

    Re: Long text to break in parts, lines

    Please Login or Register  to view this content.
    I have renamed the macro (although this should make no difference) and added TRIM to remove leading blanks should they occur.

    I cannot do anymore as it ALWAYS works when I use it so there is no logical reason for it not to work for you.

    =LinesX64(A1)
    Attached Files Attached Files
    Last edited by JohnTopley; 06-17-2021 at 04:24 AM.

  25. #25
    Registered User
    Join Date
    12-04-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 365
    Posts
    55

    Re: Long text to break in parts, lines

    Thanks that worked almost for me, only when i check some lines manually they are more than 64, not too much but 67 i saw.

    I wonder why only those lines were not limited to 64, and rest all were done perfectly.

  26. #26
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,673

    Re: Long text to break in parts, lines

    Post example of lines > 64.

  27. #27
    Registered User
    Join Date
    12-04-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 365
    Posts
    55

    Re: Long text to break in parts, lines

    Hi
    Attached sample of 1 record and below found one sentence with 67 after using the code.
    pls advise.
    Attached Files Attached Files

  28. #28
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,673

    Re: Long text to break in parts, lines

    I can't find why the odd case occurs: I will see if the VBA can be done differently but handing control characters is the issue.

  29. #29
    Registered User
    Join Date
    12-04-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 365
    Posts
    55

    Re: Long text to break in parts, lines

    Yes.. Thanks.
    I was also surprised, first thought maybe special characters was issue, but that too i checked by replacing.
    but my 95 % work is done now.
    Would be better if that odd part is removed too.

  30. #30
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,673

    Re: Long text to break in parts, lines

    You can always pass it over the the VBA experts (I'm not one!) but hopefully you can manage with a few minor manual interventions.

+ 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 do I break up a long text cell into shorter ones withoug spli.
    By kevin frisch in forum Excel General
    Replies: 5
    Last Post: 11-05-2014, 01:49 AM
  2. Split long text in two parts
    By Marvin85 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-23-2014, 03:12 PM
  3. Text to Excel with pre-defined break lines using Macro
    By jameel30 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-13-2012, 02:43 PM
  4. Break long lines of code, Map enter key with OnKey
    By capngene in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-04-2012, 08:22 AM
  5. Break long range into 2 code lines
    By ker9 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-13-2011, 01:50 PM
  6. Formula to Break an Address into it's Parts
    By robert_shindorf in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-27-2010, 02:18 PM
  7. [SOLVED] Break cell into multiple lines by line break
    By Chia in forum Excel General
    Replies: 1
    Last Post: 08-20-2006, 01:40 AM
  8. Replies: 2
    Last Post: 09-14-2005, 09:05 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