+ Reply to Thread
Results 1 to 7 of 7

Characters.delete only works with less than 255 characters?

  1. #1
    Registered User
    Join Date
    08-27-2012
    Location
    Roma, Italia
    MS-Off Ver
    Excel 2003
    Posts
    60

    Characters.delete only works with less than 255 characters?

    Long time reader, first time poster!

    I'm having an interesting bug... in vba, Characters.delete only works on cells that have less than 255 characters, but I can change the color with no problem. Check this out... post this in a workbook in cells A1 and A2 respectively:

    Please Login or Register  to view this content.
    Then select A1 and run this macro:
    Please Login or Register  to view this content.
    See how it works fine for the first entry, but the second only colors, but doesn't delete font?

    How can I work around this?

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Characters.delete only works with less than 255 characters?

    Hi mexindian,

    Maybe:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    11-25-2008
    Location
    Poland
    MS-Off Ver
    MSO 2K3, 2K10
    Posts
    84

    Re: Characters.delete only works with less than 255 characters?

    mexindian, try this:
    Please Login or Register  to view this content.
    Artik

  4. #4
    Registered User
    Join Date
    08-27-2012
    Location
    Roma, Italia
    MS-Off Ver
    Excel 2003
    Posts
    60

    Re: Characters.delete only works with less than 255 characters?

    xladept... thanks for trying, but you can't change the values of the cell after the formatting (also even search/replace doesn't work).

    Arti K solved it... first read WHERE the formatting changes are required, then delete, then reapply formatting. Smart way to do it, thanks! This is solved.

  5. #5
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Characters.delete only works with less than 255 characters?

    @ mexindian

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  6. #6
    Registered User
    Join Date
    08-27-2012
    Location
    Roma, Italia
    MS-Off Ver
    Excel 2003
    Posts
    60

    Re: Characters.delete only works with less than 255 characters?

    Thanks Cutter, will keep in mind henceforth

  7. #7
    Registered User
    Join Date
    08-27-2012
    Location
    Roma, Italia
    MS-Off Ver
    Excel 2003
    Posts
    60

    Re: Characters.delete only works with less than 255 characters?

    Even tho this is solved, I figured I'd share my final iteration in case it's useful for anyone...

    Even though Artik's solution worked perfectly, I found a problem in the case I needed to delimit by more than one thing... what this macro does is it finds any of four characters, then deletes that specific character, then paints everything between the preceding ":" and that character. Depending on which of the four characters it finds, it paints things different colours. Since it deletes first, and applies the formatting later, this allows me to not have to worry about cells that have more than 255 characters.

    It's cool because as I delete the characters (or more correctly, replace them by blank), the position in the cell changes, but we can account for it by simply counting how many deletions we make.

    Please Login or Register  to view this content.

+ 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