Solved

Run a macro every xx seconds

Posted on 2013-01-17
3
388 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

808 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