Closed Thread
Results 1 to 8 of 8

How do I limit words in a cell

  1. #1
    Registered User
    Join Date
    09-28-2010
    Location
    ny
    MS-Off Ver
    Excel 2003
    Posts
    3

    Thumbs up How do I limit words in a cell

    Hi I have a string of words that I would want to limit to 12 Characters by deleting the last words

    For example "Hi how are you doing" should be "Hi how are"

    How would I do this ?
    Last edited by emosquito; 09-29-2010 at 12:47 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How do I limit words in a cell

    Hi,

    Are you wanting to delete complete words leaving a maximum of 12 characters and perhaps fewer as in this example where 10 characters cover complete words?

    Are you counting spaces as a character?

    Rgds
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    09-28-2010
    Location
    ny
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: How do I limit words in a cell

    I want to leave a max of 12 characters,
    and let it delete the words that run over 12+ so that the final string could be less than 12

    "Hello how do you do sir" should become "Hello how do"

    and

    "That elephant is large" should become "That" not "That elephan"

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How do I limit words in a cell

    No one has mentioned yet, this can only be done in a cell by activating some VBA on the sheet, a ws_change event watchdogging that particular column.

    Is VBA OK? Not everyone wants macros enabled on their workbooks...

    What column? Starting at what row?
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Registered User
    Join Date
    09-28-2010
    Location
    ny
    MS-Off Ver
    Excel 2003
    Posts
    3

    Thumbs up Re: How do I limit words in a cell

    Ok I solved it using some nifty stuff I found, it needed 2 cell instead of 1 but it worked:

    Assuming the info was in A1

    Cell B1 Formula (This gets rid of words after character #13 and if a word is going through position 13 it displays that word):

    =IF(LEN(A1)>12,(RIGHT(LEFT(A1,13),LEN(LEFT(A1,13))-FIND("^^",SUBSTITUTE(LEFT(A1,13)," ","^^",LEN(LEFT(A1,13))
    -LEN(SUBSTITUTE(LEFT(A1,13)," ","")))))),"")


    Cell C1 Formula (This subtracts the word spit out from b1 from a1):

    =LEFT(LEFT(A1,12),((LEN(LEFT(A1,13)))-(LEN(B1))))

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How do I limit words in a cell

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  7. #7
    Registered User
    Join Date
    09-27-2020
    Location
    philippines
    MS-Off Ver
    M365
    Posts
    36
    Quote Originally Posted by emosquito View Post
    Ok I solved it using some nifty stuff I found, it needed 2 cell instead of 1 but it worked:

    Assuming the info was in A1

    Cell B1 Formula (This gets rid of words after character #13 and if a word is going through position 13 it displays that word):

    =IF(LEN(A1)>12,(RIGHT(LEFT(A1,13),LEN(LEFT(A1,13))-FIND("^^",SUBSTITUTE(LEFT(A1,13)," ","^^",LEN(LEFT(A1,13))
    -LEN(SUBSTITUTE(LEFT(A1,13)," ","")))))),"")


    Cell C1 Formula (This subtracts the word spit out from b1 from a1):

    =LEFT(LEFT(A1,12),((LEN(LEFT(A1,13)))-(LEN(B1))))
    hey just wanna ask if you can show the words that are in excess. not just "that"

  8. #8
    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: How do I limit words in a cell

    Hi. This is a VERY old thread. Please prepare a sample file (see yellow banner - top of page) with some expected results and start a NEW thread please. I am closing this thread, now.
    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

Closed Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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