can anyone help me automate this?

aragon123321

New Member
Joined
Jul 6, 2015
Messages
26
So I macro that checks some cells and if a limit is passed it calls another sub that send a message.
It is set up now to work when I click a command button to get this macro to work.
Is there any way in Vba for me to have my macro run every hour as long as my PC is on?


Sub Step1()
Dim Cell, Result As String, I As Long


For I = 3 To 2


If Cells(I, 2).Value > Cells(22, 2) Then


Call Step2(" Error Limit Passed 7/16/2015", "5623523859@txt.att.net", "bob.s@bob.bob.com")
Call C
Exit Sub
End If


Next
Range("B1").Value = "pass"
Call C


Exit Sub
End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
You could build a user form, with a box that has the timer amt...1 hr
keep the form open to trigger the timer
The ON TIMER trigger would run your Sub.

Rich (BB code):
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">''//Here's the code that goes in the user form
Dim nextTriggerTime AsDate

PrivateSub UserForm_Initialize()
    ScheduleNextTrigger
EndSub

PrivateSub UserForm_Terminate()
    Application.OnTime nextTriggerTime,"modUserformTimer.OnTimer", Schedule:=False
EndSub

PrivateSub ScheduleNextTrigger()
    nextTriggerTime = Now + TimeValue("01:00:00")
    Application.OnTime nextTriggerTime,"modUserformTimer.OnTimer"
EndSub

PublicSub OnTimer()
    ''//... Trigger whatever task you want here
    STEP1

    ''//Then schedule it to run again
    ScheduleNextTrigger
EndSub

''// Now the code in the modUserformTimer module
PublicSub OnTimer()
    MyUserForm.OnTimer
EndSub
</code>
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,449
Members
448,966
Latest member
DannyC96

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