Solved

Run a macro every xx seconds

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel VBA - Returning results from batch file 9 65
Boolean help 6 27
Easy Excel formula needed 4 23
Excel - find text within text? 1 19
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

932 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

18 Experts available now in Live!

Get 1:1 Help Now