how to disable "blinking" of comments during Application.OnTime update?

Special K

Board Regular
Joined
Jun 20, 2011
Messages
83
Office Version
  1. 2010
Platform
  1. Windows
I use the following code to implement a stopwatch:

Code:
Dim NextTick As Date
Dim t As Date
Dim PreviousTimerValue As Date


Sub StartTime()

    PreviousTimerValue = Sheets("timer_test").Range("O2").Value
    t = Time
    Call ExcelStopWatch

End Sub

Sub ExcelStopWatch()

    Sheets("timer_test").Range("O2").Value = Format(Time - t + PreviousTimerValue, "hh:mm:ss")
    NextTick = Now + TimeValue("00:00:01")
    Application.OnTime NextTick, "ExcelStopWatch"

End Sub

Sub StopClock()

    On Error Resume Next
    Application.OnTime earliesttime:=NextTick, procedure:="ExcelStopWatch", schedule:=False

End Sub

Sub Reset()

It works correctly, but the problem I am having is that the screen "blinks" every time the ExcelStopWatch Sub is called to update the timer cell, i.e. once per second. I am trying to read comments underneath my mouse cursor during this time, and every time the clock updates, the comments "blink" off and on again, making them extremely difficult to read. Is it possible to disable this "blinking" that is affecting the comments?
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
On any script putting these two lines of code at the beginning and end of your scripts will turn off screen updating.

Put your code between these two lines of code:

Code:
Application.ScreenUpdating = False
Application.ScreenUpdating = True

In your case where you are running several subs just put these two lines in the Master sub
 
Last edited:
Upvote 0
On any script putting these two lines of code at the beginning and end of your scripts will turn off screen updating.

Put your code between these two lines of code:

Code:
Application.ScreenUpdating = False
Application.ScreenUpdating = True

In your case where you are running several subs just put these two lines in the Master sub

I tried that but it had no effect. The clock kept updating every second and comments would flicker every second while I was moused over them. After reading the documentation for the Application.ScreenUpdating functions, I'm not sure what I'm trying to do is possible. I need the cell containing the real-time clock to update every second, but I don't want the comments in other cells to "flicker" every second while I'm moused over them. If it were possible to disable screen updating, it seems it would also disable the clock's updating, correct? Maybe there is a way to split panes, put the clock in a separate pane, and only have that pane update?
 
Upvote 0
.
Try this version :

Code:
Public RunWhen As Double
Public Const cRunIntervalSeconds = 1 ' 1 seconds
Public Const cRunWhat = "The_Sub"  ' the name of the procedure to run




Sub StartTimer()
    RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
    Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, Schedule:=True
End Sub


Sub The_Sub()
Application.Cursor = xlNorthwestArrow                   'prevents mouse cusor blinking


 '[A1] = Now
 [O2] = Now


   ' Call StartTimer to schedule the procedure again
   StartTimer
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top