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