VBA to Schedule Running of Macro Based on Current Time and Environ ("username")

bepedicino

Board Regular
Joined
Sep 29, 2014
Messages
73
I am looking for some VBA that will run a macro at a specific time based on the current Environ ("username") and system time.

Time Table

User 1 = 5:00 pm
User 2 = 5:15 pm (current user)
User 3 = 5:13 pm

For example, if User 2 is the current user then the macro will only run at 5:15 pm and the users and times will be ignored.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Do you realise that this will only work if a user is logged on and has the specific workbook open at that particular time?
 
Upvote 0
Yes, gruntingmonkey I do realize that; it will not be an issue for what I am trying to achieve. In actually, that is exactly what I want it to do.

Do you realise that this will only work if a user is logged on and has the specific workbook open at that particular time?
 
Upvote 0
To clarify, the macro should meet two criteria in order to run; both the Environ$("username") and the current time will need to be true. Anyone have a suggestion?

Code:
If Environ$("username")=David then
run macro1().with 16:45:00
End if
 
Upvote 0

Forum statistics

Threads
1,213,489
Messages
6,113,949
Members
448,534
Latest member
benefuexx

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