Results 1 to 12 of 12
  1. #1
    Join Date
    Nov 2003
    Location
    Sydney
    Age
    54
    Posts
    891

    Default Need help in Excel VBA programming

    I know you guys are smart and I need your help. Is it possible to run a procedure say every 5 minutes (with the file open obviously). Some sort of timing control like the "timer" in Visual Basic.

    Thanks
    Visit my website at www.myFineWoodWork.com

  2. #2
    Join Date
    May 2003
    Location
    South Oz, the big smokey bit in the middle
    Age
    68
    Posts
    1,914

    Default

    Find brick wall. Bang head repeatedly against wall. When you awaken, it is time to run procedure again.

    Richard
    modesty forbids me to take financial reward for this advice

  3. #3
    Join Date
    Nov 2003
    Location
    Sydney
    Age
    54
    Posts
    891

    Default

    Thanks Richard. Just send me an invoice mate.

    Just found this and it is probably something I can work with

    Wait Method
    See Also Applies To Example Specifics
    Pauses a running macro until a specified time. Returns True if the specified time has arrived.

    Important The Wait method suspends all Microsoft Excel activity and may prevent you from performing other operations on your computer while Wait is in effect. However, background processes such as printing and recalculation continue.

    expression.Wait(Time)

    expression Required. An expression that returns an Application object.

    Time Required Variant. The time at which you want the macro to resume, in Microsoft Excel date format.

    Example
    This example pauses a running macro until 6:23 P.M. today.

    Application.Wait "18:23:00"
    This example pauses a running macro for approximately 10 seconds.

    newHour = Hour(Now())
    newMinute = Minute(Now())
    newSecond = Second(Now()) + 10
    waitTime = TimeSerial(newHour, newMinute, newSecond)
    Application.Wait waitTime
    This example displays a message indicating whether 10 seconds have passed.

    If Application.Wait(Now + TimeValue("0:00:10")) Then
    MsgBox "Time expired"
    End If
    Visit my website at www.myFineWoodWork.com

  4. #4
    Join Date
    Oct 2003
    Location
    Romsey Victoria
    Age
    63
    Posts
    2,102

    Default

    It's a sad day when you have to program Excel in VBA.
    Photo Gallery

  5. #5
    Join Date
    Sep 2002
    Location
    Minbun, FNQ, Australia
    Age
    66
    Posts
    1

    Default

    Why not just set the timer on the microwave oven?
    Cliff.
    If you find a post of mine that is missing a pic that you'd like to see, let me know & I'll see if I can find a copy.

  6. #6
    Join Date
    Sep 2005
    Location
    Cheltenham, Melbourne
    Age
    75
    Posts
    0

    Default

    What you're looking at is something like

    Sub Macro1()
    Timer1
    End Sub

    Sub Timer1()
    Application.Wait Now + TimeValue("00:10:00")
    Macro1
    End Sub

    Here the macro's first run triggers the timer, which in turn calls the macro on timeout. The problem is that you can't do anything whilst the the timer is running, and the only way out of the loop is with ctrl +alt +break. So it's not very useful.
    Chris
    ========================================

    Life isn't always fair

    ....................but it's better than the alternative.

  7. #7
    Join Date
    Nov 2003
    Location
    Sydney
    Age
    54
    Posts
    891

    Default

    Cheers Chris (not you Grunt )

    Harsh words Grunt. I don’t use it very often but some of my finest work is done in Excel VBA. Some users are just so comfortable with columns and rows you know.
    Visit my website at www.myFineWoodWork.com

  8. #8
    Join Date
    Nov 2003
    Location
    Sydney
    Age
    54
    Posts
    891

    Default

    Got it.

    Private Sub doThis()
        Dim PauseTime, Start

        PauseTime = 1 ' Set duration.
        Start = Timer ' Set start time.
        Do While Timer < Start + PauseTime
            DoEvents ' Yield to other processes.
        Loop
        Sheet1.Range("A1") = Now
        Call TryAgain
    End Sub


    Private Sub TryAgain()
        Call doThis
    End Sub
    Visit my website at www.myFineWoodWork.com

  9. #9
    Join Date
    Jun 1999
    Location
    Westleigh, Sydney
    Age
    78
    Posts
    1,332

    Default

    Call yerself a code cutter? If yer can't do it with edlin & Fortran, it ain't worth doin'.
    Visit my website
    Website
    Facebook

  10. #10
    Join Date
    Nov 2003
    Location
    Sydney
    Age
    54
    Posts
    891

    Default

    We are going to run a conference in a hotel. During the 2 days conference, there will be 2 computers outside the conference room so our clients can answer a simple online questionnaire. Inside the conference room there is another computer and they want to use Excel to show some graphical statistics of the questionnaire as the conference progresses.

    I am simply trying to do what they want. Anyway I’ve got it sorted.
    Visit my website at www.myFineWoodWork.com

  11. #11
    Join Date
    May 2003
    Location
    South Oz, the big smokey bit in the middle
    Age
    68
    Posts
    1,914

    Default

    Quote Originally Posted by Wongo
    Anyway I’ve got it sorted.
    Found a soft wall did you Wongo?

    Richard

  12. #12
    Join Date
    Sep 2005
    Location
    Cheltenham, Melbourne
    Age
    75
    Posts
    0

    Default

    Quote Originally Posted by AlexS
    Call yerself a code cutter? If yer can't do it with edlin & Fortran, it ain't worth doin'.
    Ye Gods....Edlin. That ages you nicely.
    Chris
    ========================================

    Life isn't always fair

    ....................but it's better than the alternative.

Tags for this Thread

Bookmarks

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
  •