+ Reply to Thread
Results 1 to 7 of 7

Need to truncate a cell if the character length is over 100

  1. #1
    Registered User
    Join Date
    11-24-2007
    Location
    Florida
    MS-Off Ver
    Various
    Posts
    64

    Need to truncate a cell if the character length is over 100

    Hello

    Can somone help me figure out how to do the following?

    Need to check if a cell is over 100 characters and if so, truncate what is over 100, insert a new cell underneath it and, append the excess to the new cell.

    It needs to make sure to preserve whole words (making sure not to break a word while truncating).

    Any help appreciated.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Need to truncate a cell if the character length is over 100

    This may help for the first part?

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-24-2007
    Location
    Florida
    MS-Off Ver
    Various
    Posts
    64

    Re: Need to truncate a cell if the character length is over 100

    That works to add the line and move extra characters. Thank you for that.

    But,

    How do I make it not split words? For example, right now with your code:

    "7.5 If PLC power is lost during the test, power down UPS, replace battery and or UPS unit as required." becomes

    "7.5 If PLC power is lost during the test, power down UPS, replace battery and or UPS unit as require
    d."

    I need it to become something like:

    "7.5 If PLC power is lost during the test, power down UPS, replace battery and or UPS unit as
    required."

    Thanks for any help

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Need to truncate a cell if the character length is over 100

    Can attach a file with some samples? To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.

  5. #5
    Registered User
    Join Date
    11-24-2007
    Location
    Florida
    MS-Off Ver
    Various
    Posts
    64

    Re: Need to truncate a cell if the character length is over 100

    Ok here is an attached workbook with 2 tabs (Unmodified, and After Macro). Truncation.xls

  6. #6
    Registered User
    Join Date
    11-24-2007
    Location
    Florida
    MS-Off Ver
    Various
    Posts
    64

    Re: Need to truncate a cell if the character length is over 100

    I managed to hobble together some code from bits and pieces that will pull the last word off of a cell value, insert a row underneith and place the word in the new row.

    Please Login or Register  to view this content.
    This is the beiginning I guess... I still need to figure out how to add some math functions. Need to see if 1 word pulled out of the string will bring the length down to 100 characters, and if not, take off more words as needed. Also need to check the newly created cell's length to see if the appended words will cause that row to go over 100 characters and adjust.

    Any help appreciated.

  7. #7
    Registered User
    Join Date
    11-24-2007
    Location
    Florida
    MS-Off Ver
    Various
    Posts
    64

    Re: Need to truncate a cell if the character length is over 100

    Well to continue further into my problem, I figured out how to do a bit of this:

    Please Login or Register  to view this content.
    Unfortunately It only works once. Furthing executions of the macro only inserts the line. Do I need to somehow empty the split array before I can fill it again?

+ 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. [SOLVED] If / then statement for character length within a cell
    By kerrya98 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-23-2012, 02:21 PM
  2. Truncate last two char on non fixed length cell
    By brusk in forum Excel General
    Replies: 4
    Last Post: 02-09-2010, 03:46 PM
  3. Sort Columns by Cell Character length?
    By paulz in forum Excel General
    Replies: 1
    Last Post: 10-16-2006, 02:33 PM
  4. Truncate cell content after a certain character
    By brakai295 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-19-2006, 07:33 AM
  5. assigning character length in a cell
    By audrey in forum Excel General
    Replies: 4
    Last Post: 07-30-2006, 11:45 AM

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