+ Reply to Thread
Results 1 to 7 of 7

Truncating text to next cell but only whole words.

  1. #1
    Registered User
    Join Date
    05-10-2010
    Location
    Dorset, England
    MS-Off Ver
    Excel 2003
    Posts
    35

    Question Truncating text to next cell but only whole words.

    Hi Guys,

    Great forum!

    I have a little problem and I was wondering if any of you geniuses may be able to help me?

    Basically I am creating an adwords campaign in excel, however adwords state that the title can noly be 25 characters and the description 35 characters.

    A lot of my titles are more than 25 characters, and I can easily truncate the cells to just display 25 chacters, however this cuts off words half way through and looks messy.

    I want to be able to display 25 max characters in the first cell, and the rest in the second cell, however only truncate where there is a space.

    Does this make sense?

    Example:

    This is a test title and it is purple has 37 characters

    I need it to do this:

    This is a test title and
    it is purple


    This seems OK, however it so happened that the 25th character was a space, what about this?

    This is an extremely satisfactory product - 41 characters

    The 25th chacter is the "i". So i would need it to go back to the space and then truncate to the next cell, like this:

    This is an extremely
    satisfactory product


    Any ideas?

    A donation would be gladly made if anyone can help.

    Cheers,

    Mike
    Last edited by mikemeadeuk; 05-10-2010 at 01:43 PM. Reason: Solved

  2. #2
    Registered User
    Join Date
    05-10-2010
    Location
    Dorset, England
    MS-Off Ver
    Excel 2003
    Posts
    35

    Re: Truncating text to next cell but only whole words.

    Hi Guys,

    I have got this from another thread which is quite useful:

    =LEFT(A1,IF(AND(LEN(A1)>25,ISNUMBER(FIND(" ",A1))),FIND("#",SUBSTITUTE(LEFT(A1,25)," ","#",25-LEN(SUBSTITUTE(LEFT(A1,25)," ","")))),25))
    This truncates the text at a space at no more than 25 characters. However the rest of the title need to go into the next cell along.

    Anyone know how to do that?

    Thanks

    Mike

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Truncating text to next cell but only whole words.

    tRY:

    =TRIM(LEFT(LEFT(A1,25),FIND("^^",SUBSTITUTE(LEFT(A1,25)," ","^^",LEN(LEFT(A1,25))-LEN(SUBSTITUTE(LEFT(A1,25)," ",""))))))

    Where A1 contains string

    Then =SUBSTITUTE(A1,B1,"")

    Where B1 contains the first formula.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  4. #4
    Registered User
    Join Date
    05-10-2010
    Location
    Dorset, England
    MS-Off Ver
    Excel 2003
    Posts
    35

    Re: Truncating text to next cell but only whole words.

    NBVC,

    WOW! You really are a genius! You fixed my problem within minutes, Id be happy to buy you a drink if you send me you paypal address.

    Cheers mate

    Mike

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Truncating text to next cell but only whole words.

    Thanks, but don't worry about it. Donate it to a worthy charity instead

  6. #6
    Registered User
    Join Date
    07-04-2013
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Truncating text to next cell but only whole words.

    Thank you so very much NBVC, your formula worked perfectly and was exactly what I needed to complete an urgent project!!!!!

  7. #7
    Registered User
    Join Date
    08-15-2014
    Location
    Sao Paulo, Brazil
    MS-Off Ver
    2010
    Posts
    1

    Re: Truncating text to next cell but only whole words.

    NBVC,
    thank you. Just found this and it was way more elegant then my previous solution....
    One question only: what does the "^^" represent?

    Cheers!

+ Reply to 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