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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
.
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

Forum statistics

Threads
1,214,386
Messages
6,119,217
Members
448,876
Latest member
Solitario

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