+ Reply to Thread
Results 1 to 6 of 6

Macro is removing repeated characters from a cell

  1. #1
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Macro is removing repeated characters from a cell

    Hello all, I have a macro that is sending commands to an open window.

    If the cell contains a repeated character, it ignores all but the first character.

    For example: add becomes ad.

    If I change the cell to something that does not have repeated characters, it sends normally.

    Any thoughts?

    [edit]
    Additional examples:
    00 becomes 0. (This is an extreme problem!!!!)
    ... becomes .
    Last edited by ussenterprise; 09-30-2016 at 10:36 AM.
    Rep is appreciated. Click my * if I helped.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,330

    Re: Macro is removing repeated characters from a cell

    Hi ussenterprise,

    Are you using SendKeys? I'd put a DoEvents just after each SendKeys to allow the OS Keyboard handler time to process the information. If you don't wait a bit VBA just simply keeps sending then without the OS having time to deal with each keystroke.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Macro is removing repeated characters from a cell

    Hi MarvinP. No. I've not had much luck with SendKeys. I'm using a different macro set.

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Macro is removing repeated characters from a cell

    You might be on to something here.... If I uncomment the Wait just before the loop, it appears to display correctly. Should I add a DoEvents as it's own line?

  5. #5
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Macro is removing repeated characters from a cell

    Thanks MarvinP! This looks like it works. (1000s of lines, so kinda hard to check each one. I suppose the device I am pushing to will tell me if there's an error! haha)

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,330

    Re: Macro is removing repeated characters from a cell

    Wow,

    I'm so glad it works. I've struggled with DoEvents (on a line by itself) many times in the past. Another killer for me is working off the event of Change in a workbook or userform. If I type the same number over the old number the event of change doesn't trigger but it does if the number is different. Fools me every time. I also don't know if two DoEvents in a row might help allow the OS to perform its actions. This is like watching electrons flow out of a socket. You simply can't see or trace them as with DoEvents and why timing in VBA code sometimes works or not.

+ 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] Removing ALL repeated letters in a cell - Help please
    By GuluGuluu in forum Excel General
    Replies: 4
    Last Post: 02-07-2016, 09:54 AM
  2. [SOLVED] removing characters from a cell
    By tdf2437 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-17-2014, 06:21 PM
  3. Excel 2007 : Removing characters in a cell
    By whofan in forum Excel General
    Replies: 24
    Last Post: 09-23-2011, 01:30 PM
  4. Removing characters from the end of a cell
    By KJW in forum Excel General
    Replies: 1
    Last Post: 05-20-2010, 08:39 AM
  5. Removing Characters from a cell
    By dmthomas8 in forum Excel General
    Replies: 2
    Last Post: 04-14-2010, 12:14 PM
  6. Removing first 3 characters of cell
    By yewkiang in forum Excel General
    Replies: 2
    Last Post: 12-17-2006, 11:49 PM
  7. [SOLVED] removing some of the characters from a cell
    By Patience in forum Excel General
    Replies: 2
    Last Post: 05-03-2005, 04:06 PM

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