+ Reply to Thread
Results 1 to 2 of 2

Split Long Text Cell into Two Shorter Cells Without Splitting Word

  1. #1
    Naomi T
    Guest

    Split Long Text Cell into Two Shorter Cells Without Splitting Word

    I have text cells that are up to 60 characters in length that I need to break
    into 2 separate cells, each cell can be up to 30 characters long without
    splitting up any words. So, if the 30th character splits a word, it should
    split to the second cell at the previous space.

    How do I set up a formula to do this? I figured that if I wanted the first
    30 characters, I could use the formula (if the text was in A1) =LEFT(A1,30).
    But this splits any words.

    Thanks in advance!

  2. #2
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Of course you cannot.

    If you have 60 characters, and you split them at character 25 you will have 35 characters in your second cell, thereby failing your 30 character limit.

    Assuming then that you have 50 characters to split 30-30, you have a problem with the word that you do not wish to split, if it is 10 (or more) characters long and the last character is in position 30 you need to find the space that is 11 characters back, and there could be 3 or 4 spaces there on other lines.

    For a 'best try' you could use two helper columns (B and C) and extract characters 25 to 33 into there, -- into B1 put
    =Mid(A1,25,8)
    find the first space -- into C1 put
    =IF(ISERROR(FIND(" ",b1)),6,FIND(" ",b1))

    and use that to split to the first split-cell
    =Left(A1,(30-6+c1))
    and the second split-cell
    =Mid(a1,(31-6+c1),40)

    This will split most cells on a 5-character-back or 3-character-forward test, but will fail on large words.
    Last edited by Bryan Hessey; 07-07-2005 at 02:45 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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