• make macro run every 30min

    • This topic has 2 replies, 3 voices, and was last updated 24 years ago.
    Author
    Topic
    #354880

    I’ve got a macro which sorts a few cells.

    What bit of code can I add to make the macro run automatically every 30 minutes.

    Viewing 0 reply threads
    Author
    Replies
    • #522306

      You should use the Application.OnTime event. Have a look at this thread

      • #522414

        Hi
        I was playing around and with some help got this working

        Sub trapTime()
        Static myTime As Variant

        myTime = CurrentTimePlus(0, 1)
        Application.OnTime earliestTime:=TimeValue(myTime), procedure:=”PublishGraphs”

        End Sub

        Function CurrentTimePlus(intHours As Integer, intMinutes As Integer) As String

        CurrentTimePlus = Format(TimeSerial(Hour(Now) + intHours, Minute(Now) + intMinutes, _
        Second(Now)), “hh:mm”)
        End Function

        Sub PublishGraphs()
        MsgBox (“Eureka”)
        trapTime
        End Sub

        Sub CanceltrapTime()
        Static myTime As Variant

        myTime = CurrentTimePlus(0, 1)
        Application.OnTime earliestTime:=TimeValue(myTime), procedure:=”PublishGraphs”, schedule:=False

        End Sub
        ———————-
        Hope it helps.
        Geof

    Viewing 0 reply threads
    Reply To: make macro run every 30min

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: