Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Mar 2001
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts

    make macro run every 30min

    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.

  2. #2
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Kortrijk, Belgium
    Posts
    571
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: make macro run every 30min

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

  3. #3
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Levin, Manawatu-Wanganui, New Zealand
    Posts
    324
    Thanks
    9
    Thanked 28 Times in 26 Posts

    Re: make macro run every 30min

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •