Flashing label.backcolor with Do Until / loop trouble

Horspool68

New Member
Hi All ! just wrote this macro

Private Sub CommandButton1_Click()
Label1.BackColor = &HFF&
Application.Wait (Now + TimeValue("00:00:01"))
Label1.BackColor = &H8000000F
Application.Wait (Now + TimeValue("00:00:01"))
Do Until OptionButton11.Value = True
Loop
End Sub

I would like to use this on an excel file used to record production Data ( OEE ) on pressing the downtime button I would like Label1 backcolor flash from grey to red until the option button is activated. When I run this the label changers color and then my excel freezes up , is this a computer spec issue or am I missing something?:mad:
 

bewsh1987

Board Regular
try the below

Code:
Private Sub CommandButton1_Click()

My_wait_time = 1 '1 Second


    Do Until ActiveSheet.OptionButton11.Value = True
 
        ActiveSheet.Label1.BackColor = &HFF&
        
            Wait My_wait_time
        
        ActiveSheet.Label1.BackColor = &H8000000F
        
            Wait My_wait_time

    Loop


 End Sub
 
 Private Sub Wait(ByVal nSec As Long)
    nSec = nSec + Timer
    While nSec > Timer
        DoEvents
    Wend
End Sub
 

Some videos you may like

This Week's Hot Topics

Top