alex
alex

Reputation: 37

Call a macro 2 sec after a cell is changed

I would like to have macro called 2 seconds after a cell changes.

I am stuck with this code.

Any help would be appreciated.

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Target.Worksheet.Range("B2")) Is Nothing Then
    Application.OnTime Now + TimeValue("00:00:02"), Macro 
End Sub

Upvotes: 1

Views: 110

Answers (1)

ib11
ib11

Reputation: 2568

This is how you should modify your code:

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Target.Worksheet.Range("B2")) Is Nothing Then
        Application.Wait(Now + TimeValue("0:00:02"))
        Call Macro
    End If
End Sub

Upvotes: 2

Related Questions