Using a simple "Sleep" function to toggle color of text in a cell.
Wanting to achieve 500 millisecond between alternations however, Sleep 500 is not giving me the half second pause and more like a 5 second total time.
I've changed the value from 500 all the way down to 0.5 and minimal change in alternating time. Best I can get is 4 second s to alternate 3 times.
Am I missing something?
Wanting to achieve 500 millisecond between alternations however, Sleep 500 is not giving me the half second pause and more like a 5 second total time.
I've changed the value from 500 all the way down to 0.5 and minimal change in alternating time. Best I can get is 4 second s to alternate 3 times.
Am I missing something?
VBA Code:
Option Explicit
#If VBA7 Then ' Excel 2010 or later
Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal Milliseconds As LongPtr)
#Else ' Excel 2007 or earlier
Public Declare Sub Sleep Lib "kernel32" (ByVal Milliseconds As Long)
#End If
Sub BlinkText()
Application.ScreenUpdating = True
ActiveSheet.Range("InspectionDate").Activate 'Named range X11:AD11
Dim i As Integer
For i = 0 To 2
With Selection.Font
.Color = vbRed
.Bold = True
End With
Sleep 500
With Selection.Font
.Color = vbBlack
.Bold = False
End With
Sleep 500
Next
End Sub