+ Reply to Thread
Results 1 to 5 of 5

VBA Timer to repeat function

  1. #1
    Forum Contributor
    Join Date
    11-10-2019
    Location
    India
    MS-Off Ver
    2013
    Posts
    350

    VBA Timer to repeat function

    Hi

    I have set timer in the attached sample sheet to run every 30 seconds thru VBA but it runs only once

    I am not sure what mistake I have done hence seeking help
    Attached Files Attached Files
    Last edited by grcshekar; 09-24-2023 at 10:18 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: VBA Timer to repeat function

    When you set a timer, it only fires once. If you want it to repeat you have to set it again. In Workbook_Open you set the timer to call recalculate but then recalculate does not reset the timer. It needs the same code as in Workbook_Open to set the timer.

    You have some other problems in Workbook_Open:

    • You set range_Timer to A1 but then refer to range_Timer.Range("A1"). This will not cause an error but is redundant.
    • The value on sheet Timer is already a time value so does not need to be converted to text and then back to time.
    • You flow through to your error handler code so it will execute every time, even when there is no error.


    Also recalculate should be a Sub, not a Function. It does not return anything.

    I have fixed these problems as well.
    Attached Files Attached Files
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: VBA Timer to repeat function

    Please use Report Post only to report a rule violation or other concern that must be reviewed by Moderators. If you wish to respond to a thread post, just click Reply.

    Quote Originally Posted by grcshekar
    grcshekar has reported a post.

    Reason:
    Thank you
    Post: VBA Timer to repeat function
    Forum: Excel Programming / VBA / Macros
    Assigned Moderators: Leith Ross, dominicb, Ron Coderre, daddylonglegs, Paul, JBeaucaire, DonkeyOte, zbor, jeffreybrown, 6StringJazzer, alansidman, arlu1201, vlady, Fotis1991, FDibbins

    Posted by: 6StringJazzer
    Last edited by 6StringJazzer; 09-25-2023 at 08:00 AM. Reason: cut down quote

  4. #4
    Forum Contributor
    Join Date
    11-10-2019
    Location
    India
    MS-Off Ver
    2013
    Posts
    350

    Re: VBA Timer to repeat function

    Apoloiges instead of post it became report
    Last edited by 6StringJazzer; 09-25-2023 at 08:00 AM. Reason: removed quote of entire post

  5. #5
    Forum Contributor
    Join Date
    11-10-2019
    Location
    India
    MS-Off Ver
    2013
    Posts
    350

    Re: VBA Timer to repeat function

    Thank you it worked
    Last edited by 6StringJazzer; 09-25-2023 at 07:59 AM. Reason: removed quote of entire post

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Vba macro
    By tingxuann98 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-01-2021, 09:11 AM
  2. Have a message box repeat on timer
    By scaffdog845 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-24-2019, 01:59 PM
  3. Countdown timer Working BUT starting the timer repeatedly SPEEDS UP TIMER!
    By Vinospam in forum Excel Programming / VBA / Macros
    Replies: 67
    Last Post: 03-30-2019, 06:42 PM
  4. Replies: 1
    Last Post: 12-12-2012, 08:46 PM
  5. [SOLVED] Timer function help
    By sammijojo412 in forum Outlook Programming / VBA / Macros
    Replies: 1
    Last Post: 05-11-2012, 02:30 PM
  6. Timer function
    By q5 in forum Excel General
    Replies: 2
    Last Post: 10-19-2005, 12:05 AM
  7. Timer function
    By zoot in forum Excel General
    Replies: 2
    Last Post: 02-13-2005, 10:06 AM

Tags for this Thread

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