(Solved) – Clear cell each 10 seconds in worksheet change

(solved)-–-clear-cell-each-10-seconds-in-worksheet-change

In the following code I am trying to make the cell A1 empty each 10 seconds and at the same time to be able to work on the other cells or even any other worksheet without interrupt.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim t As Date

If Target.Address = "$A$1" Then
    t = Now()   TimeSerial(0, 0, 10)
    Do

        If Now() >= t Then
        Application.EnableEvents = False
            Range("A1").ClearContents
            Application.EnableEvents = True
            Exit Do
            End If
        DoEvents
    Loop
End If
End Sub

The code may work and clear the cell contents but sometimes I found that it is not cleared and filled with the value entered in another cell. Any idea how to fix that?

Leave a Reply

Your email address will not be published. Required fields are marked *