scheduling a macro to run

felpslima

New Member
Joined
Sep 16, 2010
Messages
11
Hello,

I have a macro GERA, that I need to be run from 10:20 a.m. to 16:20 a.m, hourly.

Can anyone help me?

thanks!
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I've found that post, but the problem is that it has two parts...
one to run at a given time and another tha t runs it 15 minutes after running the first one.

I've tried to add them up, but it didn't work.
 
Upvote 0
well, i've found some things and arraged thing so as to fit what I need, but still it does not work.

any sugestions?


Private Sub Workbook_Open()
Dim CurMin As Integer, CurHr As Integer
Dim StartTime As Date
CurMin = CInt(Right(Format(Time, "HH:MM"), 2))
CurHr = CInt(Left(Format(Time, "HH:MM"), 2))

If CurMin = 20 Then
Call Gera
ElseIf CurMin > 21 Then
If CurHr < 15 Then

StartTime = TimeValue(CurHr + 1 & ":20:00")
Application.OnTime StartTime, "Gera"
Else

StartTime = TimeValue("10:20:00")
Application.OnTime StartTime, "Gera"
End If
Else

StartTime = TimeValue(CurHr & ":20:00")
Application.OnTime StartTime, "Gera"
End If

End Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,537
Messages
6,179,405
Members
452,911
Latest member
a_barila

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