+ Reply to Thread
Results 1 to 9 of 9

Break Cell based on character count-w/o splitting words-Help

  1. #1
    Registered User
    Join Date
    12-17-2013
    Location
    Minnesota
    MS-Off Ver
    Excel 2003
    Posts
    10

    Break Cell based on character count-w/o splitting words-Help

    Hey Folks,
    I just registered for this forum but I have been using it for a while now looking for/finding help. Hoping someone out there can help me with an issue I run into frequently at work. We do large loads of new part #'s/descriptions/UPC's/etc from excel into our database. The fields are limited on character count and I would like help writing a formula to break the contents of a cell based on character count without breaking a word.
    Examples
    Column A Current Data
    Row1: 12Pt HD Offset Striking Wrench 1-3/8" & 35MM (44 characters)
    Row2: 12Pt 1/2" Drv Socket 27MM (25 characters)
    Row3: 12Pt Satin Combo Wrench 11/16" (30 characters)
    Row4: 12Pt 1/2" Drv Deep Socket 1-1/8" (32 characters)

    Results I'm Looking For

    Row1: Column B-12Pt HD Offset Striking Wrench Column C- 1-3/8" & 35MM
    Row2: Column B-12Pt 1/2" Drv Socket 27MM Column C-No Data Returned
    Row3: Column B-12Pt Satin Combo Wrench 11/16" Column C-No Data Returned
    Row4: Column B-12Pt 1/2" Drv Deep Socket Column C-1-1/8"

    Thanks in advance for any help you folks can offer.
    -Eric

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Break Cell based on character count-w/o splitting words-Help

    You just need to find the last space prior to exceeding the character limit.

    Can you provide the character limit per line?
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  3. #3
    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: Break Cell based on character count-w/o splitting words-Help

    Based on your example only:

    In B1

    =IF(ISERROR(LEFT(A1,FIND("-",A1)-1)),A1,LEFT(A1,FIND("-",A1)-1))

    In C1

    =SUBSTITUTE(A1,IF(ISERROR(LEFT(A1,FIND("-",A1)-1)),A1,LEFT(A1,FIND("-",A1))),"")

    A
    B
    C
    1
    12Pt HD Offset Striking Wrench 1-3/8" & 35MM 12Pt HD Offset Striking Wrench 1 3/8" & 35MM
    2
    12Pt 1/2" Drv Socket 27MM 12Pt 1/2" Drv Socket 27MM
    3
    12Pt Satin Combo Wrench 11/16" 12Pt Satin Combo Wrench 11/16"
    4
    12Pt 1/2" Drv Deep Socket 1-1/8" 12Pt 1/2" Drv Deep Socket 1 1/8"
    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

  4. #4
    Registered User
    Join Date
    12-17-2013
    Location
    Minnesota
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Break Cell based on character count-w/o splitting words-Help

    Need the cell to break at a 30 character max, and not break a word or sting of #'s.
    Thanks

  5. #5
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Break Cell based on character count-w/o splitting words-Help

    B1: =IF(OR(MID(A1,31,1)=" ",MID(A1,31,1)=""),LEFT(A1,30),LEFT(LEFT(A1,30),MAX((MID(LEFT(A1,30),ROW($1:$70),1)=" ")*ROW($1:$70))))

    B1 is an array formula. It is confirmed holding Control+Shift+Enter to exit the cell.

    C1: =TRIM(SUBSTITUTE(A1,B1,""))

    Then copy these two downwards as needed.

    text to columns with character limits.xlsx
    Last edited by daffodil11; 12-18-2013 at 04:58 PM.

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

    Re: Break Cell based on character count-w/o splitting words-Help

    Non-Array formula
    In B1
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    In C1
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    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

  7. #7
    Registered User
    Join Date
    12-17-2013
    Location
    Minnesota
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Break Cell based on character count-w/o splitting words-Help

    daffodil-that worked perfect, thanks!
    chemist-that formula split cells that were under 30 character and moved that last word into the next cell, but close

    Thanks for all the help!

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Break Cell based on character count-w/o splitting words-Help

    Try this for the formula in cell B1:

    =LEFT(A1,LOOKUP(30,FIND(" ",A1&" ",ROW(INDIRECT("1:30"))))-1)
    Last edited by Tony Valko; 12-18-2013 at 07:34 PM.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

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

    Re: Break Cell based on character count-w/o splitting words-Help

    Minor modification to correct for that
    =IFERROR(TRIM(LEFT(A1,FIND(" ",A1,LOOKUP(31,FIND("*",SUBSTITUTE(A1&" "," ","*",ROW(A1:A9))))))),A1)

    and a simpler equation for C1
    =TRIM(SUBSTITUTE(A1,B1,""))

+ 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. Formula to Spit up Cells based on words and character length
    By excellearner9 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-01-2016, 07:27 PM
  2. [SOLVED] Break a line of text at specfied character count
    By kazphilips in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-14-2013, 12:45 AM
  3. Splitting a cell at a certian character
    By kelemvor in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-19-2013, 02:36 PM
  4. Replies: 3
    Last Post: 12-21-2012, 05:33 AM
  5. Splitting Columns at nth character and at a word break
    By whitey4545 in forum Excel General
    Replies: 1
    Last Post: 10-31-2012, 08:44 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