+ Reply to Thread
Results 1 to 12 of 12

How Do I Truncate Text in Cells?

  1. #1
    Registered User
    Join Date
    01-09-2007
    Posts
    43

    Question How Do I Truncate Text in Cells?

    Hi,

    I have a selection of phrases listed in an excel spreadsheet. Some of them are quite long and I need to shorten them. How do I shorten them to 25 characters in each cell?

    Thanks,
    Alex
    Last edited by byepeeps; 07-13-2010 at 09:30 AM.

  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,445

    Re: How Do I Truncate Text in Cells?

    1st 25 characters =LEFT(A1,25)
    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
    Registered User
    Join Date
    01-09-2007
    Posts
    43

    Re: How Do I Truncate Text in Cells?

    Quote Originally Posted by sweep View Post
    1st 25 characters =LEFT(A1,25)
    Thanks sweep that works great. Is there any way to do it so it doesn't cut off the middle of a word? So essentially 25 characters max but only leaving whole words left. Otherwise I'll have to edit the list.

    Thanks,
    Alex

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: How Do I Truncate Text in Cells?

    More info about your data would need..

    This perhaps: =LEFT(H32,MIN(25, FIND(" ",H32)-1))

  5. #5
    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,445

    Re: How Do I Truncate Text in Cells?

    or

    =LEFT(A1,MAX(23,FIND(" ",A1,25)))

    (glass half full)

  6. #6
    Registered User
    Join Date
    01-09-2007
    Posts
    43

    Re: How Do I Truncate Text in Cells?

    Thanks for your replies.

    zbor: your suggestion cut too much off
    sweep: yours was almost there but it left too much and there was 1 error when I ran it over a few cells.

    I've attached a dummy sheet. Are you able to have a go with it? I want to truncate column E, leaving a maximum of 25 characters (including spaces) in column F. Again leaving full words would be great.

    Thanks so much,
    Alex
    Attached Files Attached Files

  7. #7
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: How Do I Truncate Text in Cells?

    Here:

    =LEFT(E1,MIN(25, FIND(" ",E1,10)-1))

  8. #8
    Registered User
    Join Date
    01-09-2007
    Posts
    43

    Re: How Do I Truncate Text in Cells?

    Thanks zbor,

    If you have time I'd be interested to know what each part of the formula means.

    Thanks again,
    Alex

  9. #9
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: How Do I Truncate Text in Cells?

    Sure...

    Formul =LEFT(E1,number) cut number characters from the left of the string in E1.

    Now, since you don't want to put manually 25 characters like sweep write in first solution you have do:

    MIN(25, FIND(" ",E1,10)-1)

    Which will return number where it finds empty place in a word. If it's too long it will return 25 characters.

    FIND(" ",E1,10)-1)

    Will return first space after 10th caracter.

    So

    Find space after 10th (red) character :

    Yamaha TP4204ACL(space)Standard Timpani Set of 4 (23", 26", 29", 32") with Covers

    =LEFT(E1;MIN(25; FIND(" ";E1;10)-1))
    =LEFT(E1;MIN(25; 15-1))
    =LEFT(E1;MIN(25; 14))
    =LEFT(E1;14)
    =Yamaha TP4204ACL

  10. #10
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: How Do I Truncate Text in Cells?

    hmm shouldnt rows 2,5,9 be
    Yamaha YBS-62S Pro
    Yamaha YSH-411SWC Brass
    Yamaha YSH-411WC Brass ?
    to get nearest to <=25 try
    =IF(OR(LEFT(A1,26)=" ",LEN(TRIM(A1))=LEN(LEFT(TRIM(A1),25))),LEFT(TRIM(A1),25),LEFT(TRIM(A1),FIND("^",SUBSTITUTE(TRIM(A1)," ","^",25-LEN(SUBSTITUTE(TRIM(LEFT(A1,25))," ",""))))-1))
    Last edited by martindwilson; 07-13-2010 at 08:13 AM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  11. #11
    Registered User
    Join Date
    01-09-2007
    Posts
    43

    Talking Re: How Do I Truncate Text in Cells?

    zbor: thanks for that. I think I understand. All a bit complex for me. Not sure what the -1 is for?

    martindwilson: You are most definitely right! Thank you for that formula. It must have taken some time to write. I don't know how you do it. Hat off to you sir!

    Thanks to all 3 of you because these formulae give me different options for different situations.

  12. #12
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: How Do I Truncate Text in Cells?

    Quote Originally Posted by byepeeps View Post
    Not sure what the -1 is for?
    FIND space will return position of space (i.e. 5 in word abcd efgh)

    So to take first word out you need 4 character, not 5.

    Therefore FIND space and -1 to get first word.

+ 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