philhowell said:
hi,
i have a VBA macro that i only wish to run between 12pm an 1am and for a specified user name (stored in options > General) .......
Howdy Phil, you could try something like the following:
<font face=Courier New><SPAN style="color:darkblue">Sub</SPAN> TriFactor()
<SPAN style="color:darkblue">Select</SPAN> <SPAN style="color:darkblue">Case</SPAN> Time
<SPAN style="color:darkblue">Case</SPAN> <SPAN style="color:darkblue">Is</SPAN> <= 0.04
<SPAN style="color:darkblue">Case</SPAN> <SPAN style="color:darkblue">Is</SPAN> >= 0.5
<SPAN style="color:darkblue">Case</SPAN> <SPAN style="color:darkblue">Else</SPAN>
<SPAN style="color:darkblue">Exit</SPAN> <SPAN style="color:darkblue">Sub</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Select</SPAN>
<SPAN style="color:darkblue">If</SPAN> Application.UserName = "Phil" <SPAN style="color:darkblue">Then</SPAN>
MsgBox "All three contingencies met."
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN></FONT>
Grabbing the windows user name is a different animal involving an api, relatively straight-forward. Hope this helps.