Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default How can I control the macro's running time?

I create one macro to grad the updated info and paste it to another spread.
then thing is it will take a while for the data update. so is there anyway to
control the macro's running time. i.e. after it excute some of the code, what
kind of code could halt the macro for 1 minute then keep running again.

thanks a lot for your help.

Ming

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default How can I control the macro's running time?

Dim StartTime as Date
StartTime = Now()
' Begin the update process here
While Now() <= (StartTime + TimeValue("00:01:00")) ' 1 minute delay
DoEvents
WEnd
' continue your processing here.

What would be better would be to actually monitor your update, if you can,
to see when it is done. For example, if you are refreshing a query with
MSQuery or ADO, you could check the .Refreshing property to see if it is done
and use that as a condition to end the loop (keeping the time check as well
to give a 'timeout' value in case the query hangs). But without knowing what
you are updating I cannot give details or an example.
--
- K Dales


"Ming" wrote:

I create one macro to grad the updated info and paste it to another spread.
then thing is it will take a while for the data update. so is there anyway to
control the macro's running time. i.e. after it excute some of the code, what
kind of code could halt the macro for 1 minute then keep running again.

thanks a lot for your help.

Ming

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default How can I control the macro's running time?

you're right on it. thanks a lot for your help.

"K Dales" wrote:

Dim StartTime as Date
StartTime = Now()
' Begin the update process here
While Now() <= (StartTime + TimeValue("00:01:00")) ' 1 minute delay
DoEvents
WEnd
' continue your processing here.

What would be better would be to actually monitor your update, if you can,
to see when it is done. For example, if you are refreshing a query with
MSQuery or ADO, you could check the .Refreshing property to see if it is done
and use that as a condition to end the loop (keeping the time check as well
to give a 'timeout' value in case the query hangs). But without knowing what
you are updating I cannot give details or an example.
--
- K Dales


"Ming" wrote:

I create one macro to grad the updated info and paste it to another spread.
then thing is it will take a while for the data update. so is there anyway to
control the macro's running time. i.e. after it excute some of the code, what
kind of code could halt the macro for 1 minute then keep running again.

thanks a lot for your help.

Ming

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How can I control the macro's running time?


Hello Ming,

The Sleep API will halt all execution from millseconds to hours. Add
new VBA module to your project anad paste the following code into it.

EXAMPLE OF STOPPING FOR 1 MINUTE
Sleep(60000)

Code
-------------------

'Time is in Milliseconds. 1 millisecond = 1/1000 of a second
Public Declare Function Sleep _
Lib "kernel32.dll" _
(ByVal dwMillisecs As Long) As Long

-------------------


Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=49560

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How can I control the macro's running time?

You can't do this.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ming" wrote in message
...
I create one macro to grad the updated info and paste it to
another spread.
then thing is it will take a while for the data update. so is
there anyway to
control the macro's running time. i.e. after it excute some of
the code, what
kind of code could halt the macro for 1 minute then keep
running again.

thanks a lot for your help.

Ming





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How can I control the macro's running time?

I misread your question. Ignore my reply.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Chip Pearson" wrote in message
...
You can't do this.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ming" wrote in message
...
I create one macro to grad the updated info and paste it to
another spread.
then thing is it will take a while for the data update. so is
there anyway to
control the macro's running time. i.e. after it excute some of
the code, what
kind of code could halt the macro for 1 minute then keep
running again.

thanks a lot for your help.

Ming





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
running macro's in Excel 2007 Texas Tonie[_2_] Excel Worksheet Functions 0 May 4th 09 07:07 PM
Running XY chart labeller using a macro's parameters and arguments. Hari Prasadh Charts and Charting in Excel 1 July 12th 05 05:00 PM
Why do i have to re-assign macro's all the time Simon Lloyd[_492_] Excel Programming 4 June 22nd 04 07:19 PM
Assigning Macro's to control buttons. catdataman Excel Programming 3 December 23rd 03 05:16 PM
shortcut key not not running macro's all of a sudden Todd Excel Programming 1 November 11th 03 08:19 PM


All times are GMT +1. The time now is 02:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"