+ Reply to Thread
Results 1 to 4 of 4

show first 50 characters in cell with only complete words

  1. #1
    Registered User
    Join Date
    02-26-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    46

    show first 50 characters in cell with only complete words

    Hi everyone,

    I'm trying to write formula (in Excel or using VBA) which shows the first 50 characters (or less) from a cell without cutting short any words. The best way I can explain this is with the example below:

    "Jack and Jill went up the hill To fetch a pail of water." - 56 characters but my maximum is 50

    "Jack and Jill went up the hill To fetch a pail of" - " water." has been removed to make the length less than 50 characters but still make sure only full words have been entered.

    Any help would be greatly appreciated.

    Thanks

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,444

    Re: show first 50 characters in cell with only complete words

    Hi,

    Try this:

    =LEFT(A1,IF(AND(LEN(A1)>50,ISNUMBER(FIND(" ",A1))),FIND("#",SUBSTITUTE(LEFT(A1,50)," ","#",50-LEN(SUBSTITUTE(LEFT(A1,50)," ","")))),50))
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: show first 50 characters in cell with only complete words

    See the green cells in the attached file.

    Please reply.
    Attached Files Attached Files
    Last edited by oeldere; 09-05-2014 at 06:29 AM. Reason: file edit (was not able to add the file)
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  4. #4
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: show first 50 characters in cell with only complete words

    if your data is in A1 TRY THIS
    =IFERROR(LEFT(A1,IF(LEN(A1)<=50,A1,51-MATCH(" ",INDEX(MID(LEFT(A1,51),51-ROW($1:$51)+1,1),0),0))),A1)
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  5. #5
    Registered User
    Join Date
    02-26-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: show first 50 characters in cell with only complete words

    These are great, thank you! I've just been going through each example to see if I can work them out. I went for nflsales' solution just because it was the easiest to understand. Sweep I found that your formula can leave a blank space at the end but it's still really appreciated. Thanks guys

+ 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. 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
  2. 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
  3. [SOLVED] Delete from a cell all words shorter than N characters
    By Buzzed Aldrin in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-10-2012, 10:06 PM
  4. How do I restrict characters whilst retaining complete words?
    By trafficbroker in forum Excel General
    Replies: 0
    Last Post: 10-11-2006, 01:07 PM
  5. How many words or characters maximum in a cell?
    By AFavoriteGirl in forum Excel General
    Replies: 2
    Last Post: 01-09-2006, 05:00 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