Application.OnTime Datevalue

Afro_Cookie

Board Regular
Joined
Mar 17, 2020
Messages
103
Office Version
  1. 365
Platform
  1. Windows
found a post, Application.ontime DateValue ???, that showed how to set a specif day of the week for an application.OnTime to run, but cannot get it to work for my file.

I want my macro to run every Friday @ 9:00AM but nothing happened when I changed the values to today in order to test. Can someone please help me out.
VBA Code:
Sub Auto_Send()

Dim NextFridayDate As Date

NextFridayDate = Date - Weekday(Date) + vbWednesday - 7 * (vbWednesday <= Weekday(Date))

Application.OnTime NextFridayDate + TimeValue("13:08:00"), "MyMacro"

End Sub
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
NextFridayDate = Date - Weekday(Date) + vbWednesday - 7 * (vbWednesday <= Weekday(Date))
This will not calculate "NextFriday" but next Wednesday... If you wish "Friday" then you should not use "vbWednesday" but "vbFriday"

And how did you set the time to "today" for testing?
Try using
VBA Code:
Application.OnTime Date + TimeValue("13:08:00"), "MyMacro"           '<<< Use the righ Timevalue

Bye
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,169
Members
453,021
Latest member
Justyna P

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