Timed intervals to run a sub-routine

MrLarrExcel

New Member
Joined
Apr 26, 2016
Messages
7
Hello everyone,
New to the forum and kinda new to the excel VBA but I know more about VB.

First I will say I work in steps meaning this question may be leading to something bigger.

Im using 2016 Pro Plus.

My goal here:
Not necessarily using the code I am providing, I wish to compare 2 cells with numeric data and if one is more that the other than give a Boolean expression of 1 else 0 in another totally separate cell. Also this needs to be done repeatedly over a specific amount of seconds by automation without any user intervention. That's all.

So far with the code I am using I am getting an error:
"Cannot run the macro 'Path to macro'. The macro may not be available in this workbook or all macros may be disabled."

I have confirmed from the Trust Center that the macros are enabled and the Trust access to the VBA project object model was checked.

The code is in the sheet.

Thank You For any help!

Code:
Option Explicit
Sub SaveData()
    Application.OnTime Now + TimeValue("00:00:10"), "FormTimer"
End Sub


Sub FormTimer()


Dim score1 As Integer, score2 As Integer, result As String
score1 = Range("B18").Value
score2 = Range("N14").Value


If score1 > score2 Then
    result = 1
Else
    result = 0
End If


Range("n16").Value = result
MsgBox "yea"
Call SaveData




End Sub
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Answered the problem myself. The code has to reside inside the module. After moving the code from the sheet to the module all worked well.
Hopes this helps someone.
Good Luck!
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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