Using a countdown timer in a cell to run a macro

nightracer

Board Regular
Joined
May 17, 2004
Messages
147
Office Version
  1. 365
Hi there

At various times during the day I need to take a snapshot of data totals in a spreadsheet.

I have a macro set to simply pick up the values in the range I need (H9:I60) and copy them as values into AA9:AA60
I also have a countdown timer running in cell F9 to the next delivery point when I need the snapshot of these totals that are formula based.

Can I use the countdown timer hitting 00:00:00 to run the macro?

Any help appreciated, thanks
N
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
That should be AA9:AB60 this first time I take the snapshot, then AD9:AE60 the next and then AG9:AE60 etc.
 
Upvote 0
.
Code:
Option Explicit


Sub shwMsg()
'The next line TimeValue sets the macro to execute every five seconds. Adjust time as required: hh:mm:ss = 00:00:05
    Application.OnTime Now + TimeValue("00:00:05"), "shwMsg"
    MsgBox "Hi !", vbOKOnly, "What ?"
End Sub

Paste the above macro into a Routine Module. You can initiate the macro either through a Command Button on the worksheet or by 'calling' it from the ThisWorkbook module in the OPEN event.

Delete this line from the above macro : MsgBox "Hi !", vbOKOnly, "What ?" and replace it with the name of your macro that performs the copying.

Adjust the time to comply with your needs. TimeValue("00:00:05"), "shwMsg" <---- presently fires the macro every 5 seconds. If you wanted the macro to execute every hour, it would be
TimeValue("01:00:00"), "shwMsg".

Hope that helps.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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