+ Reply to Thread
Results 1 to 5 of 5

How to loop over SendKeys method

  1. #1
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,785

    How to loop over SendKeys method

    Hello

    In the attached workbook and with the selection if I Press "F2" Key and then "Enter" key repeatedly the all cells are activated one by one and refreshed.During this process I was recording a macro.But I could not get an automated code for that.
    What I want is to select the CurrentRegion and keep pressing F2 and Enter ,,F2 and Enter So that that the Randbetween formula generate different digits and conditional formating is applied and as a result it should look like flashing game.
    Then I also want to stop it
    Thoughts?


    Best Regards
    Imran Bhatti
    Attached Files Attached Files
    Teach me Excel VBA

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: How to loop over SendKeys method

    If you're using RandBetween in the cells, why not just recalculate the sheet or the range...?

  3. #3
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,785

    Re: How to loop over SendKeys method

    Hello sir cytop

    Thanks that did the trick but how can I do it repeatedly?
    I mean I want to click only once and the flashing should continue until I stop it with anther action say clicking in any cell.
    I used this
    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: How to loop over SendKeys method

    Declare a public Boolean variable in a module and make sure your procedure is in that module
    Add a button or shape to the worksheet and assign/call the procedure in the click event.
    Change the procedure

    Please Login or Register  to view this content.
    Click the button/shape to start and stop.

    The DoEvents is critical. You will not be able to do anything with Excel, including stopping the code, if you do not include it

  5. #5
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,785

    Re: How to loop over SendKeys method

    Perfect.It is stopping the loop by double clicking in a cell

+ 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. sendkeys method not working!
    By excelriddles in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-13-2015, 02:00 PM
  2. [SOLVED] F2+Enter without sendkeys method
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-02-2015, 01:55 PM
  3. Find method loop problem
    By newbi004 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-09-2013, 04:27 AM
  4. Code to sum cell values using a loop method
    By qussai in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-10-2012, 09:01 AM
  5. With Loop + Find Method = Confused
    By hurricanopotamus in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-23-2010, 04:15 PM
  6. Find method loop with ColorIndex
    By yellephant in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-14-2008, 08:02 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