+ Reply to Thread
Results 1 to 6 of 6

OnTime VB

  1. #1
    AKorsakova@gmail.com
    Guest

    OnTime VB

    I want to refresh my data every day at 12am. Does something like this
    make sence?

    Public RunWhen As Double

    Sub StartTimer()

    RunWhen = Time() = #12:00:00 AM# + TimeSerial(24, 0, 0)
    Application.OnTime earliesttime:=RunWhen, procedure:="The_Sub", _
    schedule:=True
    End Sub

    Sub The_Sub()


    ActiveWorkbook.RefreshAll
    StartTimer

    End Sub


  2. #2
    Ardus Petus
    Guest

    Re: OnTime VB

    Sub StartTimer()
    Dim RunWhen As Double
    RunWhen = Time() = #12:00:00 AM# + TimeSerial(24, 0, 0)
    Application.OnTime earliesttime:=RunWhen, procedure:="The_Sub", _
    schedule:=True
    End Sub

    HTH
    --
    AP

    <AKorsakova@gmail.com> a écrit dans le message de news:
    1147783738.040546.171300@g10g2000cwb.googlegroups.com...
    >I want to refresh my data every day at 12am. Does something like this
    > make sence?
    >
    > Public RunWhen As Double
    >
    > Sub StartTimer()
    >
    > RunWhen = Time() = #12:00:00 AM# + TimeSerial(24, 0, 0)
    > Application.OnTime earliesttime:=RunWhen, procedure:="The_Sub", _
    > schedule:=True
    > End Sub
    >
    > Sub The_Sub()
    >
    >
    > ActiveWorkbook.RefreshAll
    > StartTimer
    >
    > End Sub
    >




  3. #3
    Dave Peterson
    Guest

    Re: OnTime VB

    This looks funny to me:

    RunWhen = Time() = #12:00:00 AM# + TimeSerial(24, 0, 0)

    Maybe:

    RunWhen = date + TimeSerial(23, 59, 59)
    or
    RunWhen = date + 1

    Chip Pearson has lots of instructions at:
    http://www.cpearson.com/excel/ontime.htm


    AKorsakova@gmail.com wrote:
    >
    > I want to refresh my data every day at 12am. Does something like this
    > make sence?
    >
    > Public RunWhen As Double
    >
    > Sub StartTimer()
    >
    > RunWhen = Time() = #12:00:00 AM# + TimeSerial(24, 0, 0)
    > Application.OnTime earliesttime:=RunWhen, procedure:="The_Sub", _
    > schedule:=True
    > End Sub
    >
    > Sub The_Sub()
    >
    > ActiveWorkbook.RefreshAll
    > StartTimer
    >
    > End Sub


    --

    Dave Peterson

  4. #4
    AKorsakova@gmail.com
    Guest

    Re: OnTime VB

    now with something like RunWhen = date + TimeSerial(23, 59, 59)
    would that automatically refresh every day- or would it just do that
    one day?


  5. #5
    Dave Peterson
    Guest

    Re: OnTime VB

    It would only do it once.

    But you could have your code set up the next time right after that time
    finishes.

    Chip shows you how at that link.

    AKorsakova@gmail.com wrote:
    >
    > now with something like RunWhen = date + TimeSerial(23, 59, 59)
    > would that automatically refresh every day- or would it just do that
    > one day?


    --

    Dave Peterson

  6. #6
    Chip Pearson
    Guest

    Re: OnTime VB

    It would run only once. See www.cpearson.com/excel/ontime.htm

    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    <AKorsakova@gmail.com> wrote in message
    news:1147875057.506794.41610@u72g2000cwu.googlegroups.com...
    > now with something like RunWhen = date + TimeSerial(23, 59, 59)
    > would that automatically refresh every day- or would it just do
    > that
    > one day?
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1