New Excel Forum

This forum has been moved to TeachExcel.com

Ask all future questions in the New Excel Forum.

ExcelKey

Excel-Import Data

Macros, VBA, Excel Automation, etc.

Excel-Import Data

Postby gabbie » Mon Jan 09, 2012 9:21 am

I am importing data by means of a msquery. The data is gathered from Microsoft SQL express 2005 database. I want to set up each worksheet to refresh automatically at time intervals and to only allow a restricted amount of data to transfer into the worksheet.

How do I approach this?
  • 0

gabbie
Rookie
 
Posts: 7
Joined: Jan 9, 2012
Reputation: 0

Re: Excel-Import Data

Postby Don » Mon Jan 09, 2012 10:09 am

*moved to the programming forum

Hi and welcome!

All you need to do is to use the macro inserted below and input the name of your macro. This will run the desired macro every so many minutes after the first time it is run.


Code: Select all
Sub ReRunMacro()
   
    Call test
   
    Application.OnTime Now + TimeValue("00:02:00"), "ReRunMacro"
   
End Sub


Replace "test" with the name of your macro. Change the 2 after "TimeValue" to however many minutes you want to have between running the macro.

As far as restricting the data taken in by the query, just deal with that in the macro that this macro will call.

hth!
  • 0

Don
Moderator
 
Posts: 733
Joined: Dec 4, 2011
Reputation: 2
Excel Version: 2010


Return to Macros and VBA Questions

Who is online

Users browsing this forum: Google [Bot] and 242 guests