Results 1 to 14 of 14
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    attending a time in seconds.... (2000 sr 1)

    ... and go to the netx line command.

    I have a macro and i would want to anntendinfg 480 seconds to go to the next instruction...

    example:

    sub my macro

    code
    ..............
    .............
    .............


    attending 480 seconds after go to next line

    call macro_test

    end sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: attending a time in seconds.... (2000 sr 1)

    Hi Sal,

    The Application.OnTime method is just what you need. To execute macro_test after waiting for 480 seconds, use

    Sub mymacro()
    ...
    ...
    Application.OnTime Now + TimeValue("00:08:00"), "macro_test"
    End Sub

    480 seconds = 480/60 = 8 minutes, so the start time for macro_test is the current moment (Now), plus the time corresponding to "00:08:00" (hours:minutes:seconds)

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: attending a time in seconds.... (2000 sr 1)

    tks as usual,
    but, generally, not is important to insert the command "call" to recall a macro?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: attending a time in seconds.... (2000 sr 1)

    Call is not required. To execute a procedure <code>MyProcedure</code> (it can also be a function), you can use

    <code>Call MyProcedure</code>

    or simply

    <code>MyProcedure</code>

    If the procedure (or function) has arguments, you can use

    <code>Call MyProcedure(Argument1, Argument2)</code>

    or simply

    <code>MyProcedure Argument1, Argument2</code>

    Note that the latter method does not use parentheses ( ). Look up Call in the online help for Excel VBA for more information.

    The Application.OnTime method works a bit differently, you must pass the name of the macro to be executed as a string, in quotes. Look up OnTime in the online help for Excel VBA for more information and examples.

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: attending a time in seconds.... (2000 sr 1)

    tks, Prof.

    I have always insert "call" to execute a procedure....:-(

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: attending a time in seconds.... (2000 sr 1)

    There is nothing against using Call. Some people prefer using it, others don't.

  7. #7
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: attending a time in seconds.... (2000 sr 1)

    ok! it work. but in this mode is possible to modify the sheet....
    But my problem is to not permit to midify the sheet during the attending time.

  8. #8
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: attending a time in seconds.... (2000 sr 1)

    Use

    Application.Wait Now+TimeValue("00:08:00")

    At the position where the delay is needed.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  9. #9
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: attending a time in seconds.... (2000 sr 1)

    ... uhm.......

    make a correction on mine first post, i am not sure to understand your modify

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: attending a time in seconds.... (2000 sr 1)

    Try this:

    Sub mymacro()
    ' some code
    ...
    ...
    ' pause for 8 minutes
    Application.Wait Now + TimeValue("00:08:00")
    ' call other macro
    macro_test
    End Sub

    Your users might become irritated, though! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  11. #11
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: attending a time in seconds.... (2000 sr 1)

    .... "Your users might become irritated, though!"

    why? if I have made something badly, I excuse, sorry! <img src=/S/bingo.gif border=0 alt=bingo width=15 height=22> <img src=/S/coffeetime.gif border=0 alt=coffeetime width=32 height=48> <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Sal

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: attending a time in seconds.... (2000 sr 1)

    I meant that they might not like it that they cannot use Excel for 8 minutes. But they can go for a cup of Neapolitan caffe', of course <img src=/S/coffeetime.gif border=0 alt=coffeetime width=32 height=48>

  13. #13
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: attending a time in seconds.... (2000 sr 1)

    ok! ok! i have undestand your nice note...

    but i post you tomorrow a new BIG problem with to the End print job...

    In effect all file printed from mine application Host from 7/6/2004 is changed and not have the same charactreristic to make your modify... <img src=/S/aflame.gif border=0 alt=aflame width=16 height=16>

  14. #14
    5 Star Lounger jujuraf's Avatar
    Join Date
    Jun 2001
    Location
    San Jose, California, USA
    Posts
    1,061
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: attending a time in seconds.... (2000 sr 1)

    I'd like to add a minor point to this CALL discussion....

    I always use it for two reasons:
    1. It makes the code clearer (to me anyway) in that it's obvious I'm making a call to subroutine that I wrote vs. a VBA built-in subroutine. This is expecially true for the times I need to write my own version of something that's not in an earlier version of Excel (like no Split in xl97 but it is in newer versions).

    2. It is actually REQUIRED if you execute a method from a class. I've never been able to use a class method without a CALL statement.
    <pre>call someClassObj.someMethod(arg1, arg2)</pre>

    Therefore, I always use it for the sake of consistency.

    <img src=/S/2cents.gif border=0 alt=2cents width=15 height=15> Deb

Posting Permissions

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