ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run macro on excel open if after certain time (https://www.excelbanter.com/excel-programming/382834-run-macro-excel-open-if-after-certain-time.html)

Steve

Run macro on excel open if after certain time
 
I already use this code to execute a macro if the date is Friday. I
want to amend it so that it will run only if it is before 11:00
If (Weekday(Now) = vbFriday) And Sheet5.Range("fri_weather").Value =
"" Then [Friday]

Thanks for nay help you may provide.

Thanks, Steve


JE McGimpsey

Run macro on excel open if after certain time
 
One way:

If Sheet5.Range("fri_weather") = vbNullString Then _
If WeekDay(Date) = vbFriday Then _
If Time < TimeSerial(11, 0, 0) Then _
[Friday]

In article om,
"Steve" wrote:

I already use this code to execute a macro if the date is Friday. I
want to amend it so that it will run only if it is before 11:00
If (Weekday(Now) = vbFriday) And Sheet5.Range("fri_weather").Value =
"" Then [Friday]

Thanks for nay help you may provide.

Thanks, Steve


Gary''s Student

Run macro on excel open if after certain time
 
Try something like:

Sub tcheck()
Dim v As Double
v = Now()
tm = v - Int(v)
If tm 0.45833 Then
MsgBox ("too late - after 11:00 AM")
Else
MsgBox ("its before 11:00 AM")
End If
End Sub

--
Gary's Student
gsnu200704


"Steve" wrote:

I already use this code to execute a macro if the date is Friday. I
want to amend it so that it will run only if it is before 11:00
If (Weekday(Now) = vbFriday) And Sheet5.Range("fri_weather").Value =
"" Then [Friday]

Thanks for nay help you may provide.

Thanks, Steve



Steve

Run macro on excel open if after certain time
 
On Feb 8, 8:41 am, JE McGimpsey wrote:
One way:

If Sheet5.Range("fri_weather") = vbNullString Then _
If WeekDay(Date) = vbFriday Then _
If Time < TimeSerial(11, 0, 0) Then _
[Friday]

In article om,



"Steve" wrote:
I already use this code to execute a macro if the date is Friday. I
want to amend it so that it will run only if it is before 11:00
If (Weekday(Now) = vbFriday) And Sheet5.Range("fri_weather").Value =
"" Then [Friday]


Thanks for nay help you may provide.


Thanks, Steve- Hide quoted text -


- Show quoted text -


Thank You Very Much JE . It works perfectly ! Steve



All times are GMT +1. The time now is 12:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com