Solved

Run a macro every xx seconds

Posted on 2013-01-17
3
378 Views
Last Modified: 2013-02-04
Greetings all. I have a macro that I developed that goes out and reads a database and populates a spreadsheet with the information. The database consists of over 50 test systems and I have Labview code that reads a status from the test systems and populates the database with it. The spreadsheet gets updated every time the user presses a hotkey combination. It all works the way I want.

My question here is:

Once the macro executes when the hot key is pressed, how can I have the macro repeat every xx seconds?

Below is the actual code that populates the spreadsheet:


Sub Test1()
''This code retrieves all records
    GetDataFromAccess "Z:\Database\Test Node Status Database.mdb", "TestNodeStatus", _
                      "", "=", "", _
                      "", "=", "", _
                      "", "=", "", _
                      "", "=", "", _
                      "", "=", "", _
                      "", "=", "", _
                      "", "=", "", _
                      Sheets("Test Node Status").Range("A1"), _
                      "*", True, True
End Sub

This macro calls a larger one which goes out and retrieves the data. I hope I am correct in my thinking that I only need to keep repeating this piece to actually update the spreadsheet.
0
Comment
Question by:flubbster
3 Comments
 
LVL 5

Accepted Solution

by:
sbaughan earned 125 total points
ID: 38789201
Try to add this at the end of the run:
Application.OnTime Now + TimeValue("00:00:30"), "Test_1"

Change the time offset in the string to match your need

Yes, if I understand well, you call the main function and it updates your data
0
 
LVL 14

Expert Comment

by:Don Thomson
ID: 38798558
Simplest way is the Right Mouse Click on the Macro and Create A shortcut - Put it somewhere safe.

Then use the Task Scheduler to run the macro every XX seconds
0
 
LVL 30

Author Comment

by:flubbster
ID: 38851115
Should have thought to ask this before closing the question. Once the macro is running (I have a hotkey, ctrl-r, to start it), is there a way to stop it? Assume that it is running every 30 seconds as you answered, is the only way to stop it updating by shutting it down?
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now