If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Screen flicker
Greets all,
I created a time-clock sheet at work where excel logs the times that employees clock in or out. This part works without a hitch. However, my supervisor wants the program to also track the amount of time that the employee has been on break at any given moment. What I did was set up a VBA script to do this, but this causes the screen and cursor to flicker continuously. Is there any way to stop this? With the script, I am using a Do...DoEvents...Loop with the time being updated before the DoEvents command. Example: Current time 6:17 am Employee-1 Start time 6:02 am Finish time 6:32 am Duration 15:23 The duration is in minutes and seconds, updated continuously. Thanks, Jesse. |
#2
|
|||
|
|||
Screen flicker
Jesse wrote:
With the script, I am using a Do...DoEvents...Loop with the time being updated before the DoEvents command. If he doesn't need to break into the macro, make it run say every minute by putting Application.Wait Now+TimeValue("00:01:00") in the loop. If he needs to break in, you can use Application.OnTime to run your update macro once but it's a bit more complicated: Dim NextTime As Date ' at top of standard module Sub Auto_Open() StartUpdate End Sub Sub Auto_Close() StopUpdate End Sub Sub StartUpdate() NextTime = Now + TimeValue("00:01:00") Application.OnTime Now, "DoUpdate" End Sub Sub StopUpdate() If NextTime0 Then Application.OnTime Now, "DoUpdate",Schedule:=False NextTime = 0 End If End Sub Sub DoUpdate() ' your code to do one update of the screen StartUpdate End Sub Hope this helps Bill Manville MVP - Microsoft Excel, Oxford, England No email replies please - respond to newsgroup |
#3
|
|||
|
|||
Screen flicker
Thanks Bill- the first solution worked perfectly.
Jesse. Jesse wrote: With the script, I am using a Do...DoEvents...Loop with the time being updated before the DoEvents command. If he doesn't need to break into the macro, make it run say every minute by putting Application.Wait Now+TimeValue("00:01:00") in the loop. If he needs to break in, you can use Application.OnTime to run your update macro once but it's a bit more complicated: Dim NextTime As Date ' at top of standard module Sub Auto_Open() StartUpdate End Sub Sub Auto_Close() StopUpdate End Sub Sub StartUpdate() NextTime = Now + TimeValue("00:01:00") Application.OnTime Now, "DoUpdate" End Sub Sub StopUpdate() If NextTime0 Then Application.OnTime Now, "DoUpdate",Schedule:=False NextTime = 0 End If End Sub Sub DoUpdate() ' your code to do one update of the screen StartUpdate End Sub Hope this helps Bill Manville MVP - Microsoft Excel, Oxford, England No email replies please - respond to newsgroup |
Thread Tools | |
Display Modes | |
|
|