+ Reply to Thread
Results 1 to 5 of 5

Split text in single cell to multiples of 80 characters by full words

  1. #1
    Registered User
    Join Date
    02-15-2014
    Location
    Michigan
    MS-Off Ver
    O365
    Posts
    76

    Split text in single cell to multiples of 80 characters by full words

    Hey All,

    I'm attempting to split a single cell with character counts that vary.

    I have the text in B2; in C2 and over I have a formula that breaks up the data into 80 piece blocks

    Please Login or Register  to view this content.
    What I'd like this to additionally do is only parse the data to full words under 80 characters and add a space.

    Example:

    "The Store Owner Is Really Creepy"

    for ease lets say this is parse every 8 characters:

    The Stor e Owner Is Reall y Creepy
    The Store Owner Is Really Creepy

    Saying the bottom is how I'd like to to parse, I hope that makes sense.

  2. #2
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Split text in single cell to multiples of 80 characters by full words

    Try this formula in B1 and pull it to the right until you see blanks

    =TRIM(MID(SUBSTITUTE($A1," ",REPT(" ",255)),(COLUMNS($A:A)-1)*255+1,255))

    Row\Col
    A
    B
    C
    D
    E
    F
    G
    1
    The Store Owner Is Really Creepy The Store Owner Is Really Creepy
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

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

    Re: Split text in single cell to multiples of 80 characters by full words

    I resorted to using a UDF (user defined Function) "RngConcat()" to concatenate ranges.

    In C2, the formula is simply
    =IFERROR(TRIM(LEFT($B$2,FIND(" ",$B$2,LOOKUP(81,FIND("*",SUBSTITUTE($B$2," ","*",ROW($A$1:$A$18))))))),$B$2)

    In D2 copied to the right it's
    =IF(LEN(REPLACE($B$2,1,LEN(RngConCat($C$2:C$2))+COLUMNS($A$1:A1)*2,""))<=80, REPLACE($B$2,1,LEN(RngConCat($C$2:C$2))+COLUMNS($A$1:A1)*2,""), TRIM(LEFT(REPLACE($B$2,1,LEN(RngConCat($C$2:C$2))+COLUMNS($A$1:A1)*2,""),FIND(" ",REPLACE($B$2,1,LEN(RngConCat($C$2:C$2))+COLUMNS($A$1:A1)*2,""),LOOKUP(81,FIND("*",SUBSTITUTE(REPLACE($B$2,1,LEN(RngConCat($C$2:C$2))+COLUMNS($A$1:A1)*2,"")," ","*",ROW($A$1:$A$25))))))))

    In a VBA module, use this code
    Please Login or Register  to view this content.
    See attachment. I used your formula in row 1, mine in row 2
    Attached Files Attached Files
    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

  4. #4
    Registered User
    Join Date
    02-15-2014
    Location
    Michigan
    MS-Off Ver
    O365
    Posts
    76

    Re: Split text in single cell to multiples of 80 characters by full words

    Hey Chemist,

    This works kind of if you look at your excel doc F2 & G2 the beginning of the sentence is being weird.

  5. #5
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Split text in single cell to multiples of 80 characters by full words

    Hi.

    Assuming the string of text is in A1, then, in B1:

    =MID($A1,CHOOSE(1+(COLUMNS($A:A)=1),SUMPRODUCT(LEN(A1:$B1))+1,1),LOOKUP(2,1/(1-ISNUMBER(MATCH(MID(UPPER($A1),ROW(INDIRECT(CHOOSE(1+(COLUMNS($A:A)=1),SUMPRODUCT(LEN(A1:$B1))+1,1)&":"&CHOOSE(1+(COLUMNS($A:A)=1),SUMPRODUCT(LEN(A1:$B1))+80,80))),1),INDEX(CHAR(ROW(INDIRECT("65:90"))),,),0))),ROW(INDIRECT(CHOOSE(1+(COLUMNS($A:A)=1),SUMPRODUCT(LEN(A1:$B1))+1,1)&":"&CHOOSE(1+(COLUMNS($A:A)=1),SUMPRODUCT(LEN(A1:$B1))+80,80))))-CHOOSE(1+(COLUMNS($A:A)=1),SUMPRODUCT(LEN(A1:$B1)),0))

    Copy to the right until you start to get blanks for the results.

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

+ 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. Excel formula to split words with characters limit per cell
    By montroseite in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-06-2014, 07:22 AM
  2. Truncate text in a cell after so many words or characters
    By theblade24 in forum Excel General
    Replies: 9
    Last Post: 06-07-2013, 01:29 PM
  3. Split numbers and text from a single Cell
    By wong_lizzie in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-17-2012, 08:12 AM
  4. Split String into 4 Parts - Max 30 Characters per Cell and Whole Words
    By keithm_007 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-22-2012, 05:56 AM
  5. [SOLVED] Split long text with max 30 characters keeping words intact to multiple rows using vb
    By newbi004 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-10-2012, 04:36 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