automatically place number in cell 5 sec intervals

slochin

Board Regular
Joined
Dec 1, 2015
Messages
70
Hello,
Hoping someone might be able to assist please.
I am running a program which updates some results if you place -6 in the q2 cell.I have been doing this manually but I wondered if there was a formula I could put in that would place the minus 6 (-6) number in the q2 cell say every 5 seconds.
Appreciate any help.Thank you
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
.
Paste the following in a module :

Code:
Option Explicit


Dim TimeToRun


Sub auto_open()
    Call ScheduleCopyPriceOver
End Sub


Sub ScheduleCopyPriceOver()
    TimeToRun = Now + TimeValue("00:00:05")
    Application.OnTime TimeToRun, "sTARTM"
End Sub


Sub Startm()
    Calculate
    Range("Q2").Value = "-6"
    Call ScheduleCopyPriceOver
End Sub


Sub Stopm()
    On Error Resume Next
    Application.OnTime TimeToRun, "Startm", , False
End Sub

Place two command buttons on the sheet. One attached to the Startm macro and the other attached to the Stopm macro.
 
Upvote 0
Hello Logit ,
Thank you for your prompt response.Do I take it that this requires the start button to be selected every time I start the Excel sheet? If so is it possible to have this made to start when I open the Excel sheet as all the other parts are automatic.Appreciate your assistance.
 
Upvote 0
.
You can have it run without the buttons. Just paste the macros in a module and save as .XLSM (macro enabled).

When you open the workbook, the macro auto runs itself. However, without a command button you won't be able to stop the macro
unless you close the workbook. Next time you open it, the macro auto runs again.
 
Upvote 0
Hello Logit,
Many thanks for taking the time to assist me and to provide an excellent solution to my query.
 
Upvote 0
You are welcome. Glad to help.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

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