View Single Post
 
Old 07-30-2022, 07:45 AM
Logit Logit is offline Windows 10 Office 2007
Expert
 
Join Date: Jan 2017
Posts: 533
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

excel - Flashing/ blinking a textbox with one command button - Stack Overflow

Code:
Option Explicit
Public dteStartTime As Date

Sub start_time()
Application.OnTime Now + TimeValue("00:00:01"), "next_moment"
End Sub

Sub end_time()
On Error Resume Next
Application.OnTime Now + TimeValue("00:00:01"), "next_moment", , False
On Error GoTo 0
End Sub

Sub next_moment()
If Worksheets("Sheet1").Cells(1, 1).Interior.ColorIndex = 6 Then
Worksheets("Sheet1").Cells(1, 1).Interior.ColorIndex = 0
Else
Worksheets("Sheet1").Cells(1, 1).Interior.ColorIndex = 6
End If
If dteStartTime + TimeValue("00:00:10") <= Now Then
  end_time
Else
  start_time
End If

End Sub

Sub CommandButton1_Click()
dteStartTime = Now
Call start_time
End Sub
Reply With Quote