How do I make macro run every minute?

L

Legacy 76526

Guest
Hi All,

I have a macro called MyMacro which I would like to run every minute starting from 08:00:00 and finish at 14:00:00.

Thanks for any assistance.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Thanks Tusharm,

I have managed to get the macro to run every minute by adapting Pearsons formula. WIll tackle the 0800 and 1400 hrs a little later. Thanks for your help.

For others who are also searching for a similar macro, here is the code:

Public Declare Function SetTimer Lib "user32" ( _
ByVal HWnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long

Public Declare Function KillTimer Lib "user32" ( _
ByVal HWnd As Long, _
ByVal nIDEvent As Long) As Long

Public TimerID As Long
Public TimerSeconds As Single

Sub StartTimer()
TimerSeconds = Range("A1").Value 'enter in cell(A1) the seconds between updates
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc)
End Sub

Sub EndTimer()
On Error Resume Next
KillTimer 0&, TimerID
End Sub

Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, _
ByVal nIDEvent As Long, ByVal dwTimer As Long)
MyMacro 'the name of your macro to run
End Sub
 
Upvote 0
Just curious..

What macro would you want to run every minute.
I am not trying to be critical, just curious...
 
Upvote 0
I have DDE links from the Stock exchange. I have developed my own spreadsheet that sorts stocks into %gainers and fallers and other goodies ... whilst the data is continuously updated and provides the information it must be in alphabetical order, I prefer the order to be %move, thus my macro being run every minute is useful.
 
Upvote 0
I once tried to create a spreadsheet that would update automatically, but I could never figure it out.

Would you enlighten me on how to do this?
 
Upvote 0
Tusharm (and others),

I have had the unfortunate expereince of encountering the weakness of the WIndows API that cpearson mentions in http://www.cpearson.com/excel/OnTime.aspx Whilst I am not editing a cell, the cells are being updated continuously by DDE links. It seems that when the cells are updating and the windows timer performs the macro simultaneously, Excel crashes without saving work.

Does anyone know how to get around this problem or have a better idea of how to make a macro run every minute.

Regards, Brad
 
Upvote 0

Forum statistics

Threads
1,216,512
Messages
6,131,091
Members
449,618
Latest member
lewismillar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top