PDA

View Full Version : sendkeys works once only despite time frame



Juriemagic
10-01-2015, 02:33 AM
Hi good people!,

I have searched and googled, but came up with empty hands..please help me with this little problem?

I have a sheet with data..(no surprise )..I want this data logged (copied and pasted) to different cells at specific days and times. What I have done was enter the 4 dates (on which the macro must fire), and times in 4 cells. in the 5th cell I have the formula "now()"..In the 6th cell I have a formula that will give a "1" as output when the "now" formula matches any of the four dates/times. when the cell changes to 1, I want a macro fired which will do the copy and paste actions..


What I am battling with is getting the sendkeys function to execute lets say every 30 sec..Please will somebody show me the way?..OR of course, if there is a better solution, I will also gladly welcome that..Thank you all..

GTO
10-01-2015, 04:36 AM
My guess would be that whatever you are aiming SendKeys at is losing focus. Regardless, at least from your initial post, it appears that you are working solely in Excel, in which case I cannot imagine SendKeys being necessary or beneficial. Could you attach your workbook and explain what you are trying to accomplish? I am afraid that due to a recent burglary I suffered, I would have to wait until I have a moment at work, but I bet you will already have received help.

Mark

Kenneth Hobs
10-01-2015, 05:02 AM
Using Now() that way would only work when a calculation occurs. This is usually done by modifying a value if automatic calculation was set.

Your better path would likely be to use Application.Ontime at some point. Now you know what to google or search for on Excel VBA forums.

As GTO said, Sendkeys() should be avoided when possible.

Mark, so sorry to hear of your loss. My main computer's hard drive went down a while back so I feel your pain in a small way. Luckily, I backup data files every so often but not as often as I should.