Home > database >  Application.OnTime throwing "Object Required" error even though I clearly put the object
Application.OnTime throwing "Object Required" error even though I clearly put the object

Time:03-24

I have a macro that is throwing an error when I attempt to schedule it to run itself later. I have pounded my face on the desk to the point of exhaustion, but no help.

It errors on the "Application.OnTime" line and says: Run-time error '424': Object required

Public Sub WaitForItGas()

rtime = Now   TimeValue("00:00:02")

If Range("GasDoneCheck").Value <> 1 Then
    DoEvents
    Applicaion.OnTime EarliestTime:=rtime, _
                      Procedure:="WaitForItGas", _
                      Schedule:=True
    DoEvents
Else
    
    MsgBox "done"

End If

End Sub

I have tried declaring the name of the procedure to schedule (in this case the name of the procedure itself), a string variable, as a public constant. I have tried setting it to schedule running another sub, which in turn runs this sub. I have tried various versions of formatting on my code. It's pretty simple code, I'm out of ideas.

CodePudding user response:

Application is spelled wrong.

Public Sub WaitForItGas()

    rtime = Now   TimeValue("00:00:02")

    If Range("GasDoneCheck").Value <> 1 Then
        DoEvents
        Application.OnTime EarliestTime:=rtime, _
            Procedure:="WaitForItGas", _
            Schedule:=True
        DoEvents
    Else
    
        MsgBox "done"

    End If

End Sub
  • Related