ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Execute VB code depending on time of day (https://www.excelbanter.com/excel-discussion-misc-queries/252712-execute-vbulletin-code-depending-time-day.html)

WA

Execute VB code depending on time of day
 
Hi,

I have the clock (24 format) in a spreadsheet. When a user clicks a button,
I would like to see the procedure executed only if it is after a certain
time. ie. if it is after 17:00, then the function will run, otherwise a msg
will state that it is too early.

I've looked at the OnTime code, but it will not serve my purpose.
Any ideas would be greatly appreciated.

Thanks,

WA

Jim Thomlinson

Execute VB code depending on time of day
 
My preference for that kind of thing would be to use the ontime method. When
the spreadsheet is opened check the time and if it is after 17:00 then enable
the button otherwise disable. Have the on time method enable the button at
17:00. That code is very lightweight. The nice thing about it is that the
user can only click the button when it is valid to do so. No need for a
message box telling the user that they can not do something that you never
intended to let them complete.
--
HTH...

Jim Thomlinson


"WA" wrote:

Hi,

I have the clock (24 format) in a spreadsheet. When a user clicks a button,
I would like to see the procedure executed only if it is after a certain
time. ie. if it is after 17:00, then the function will run, otherwise a msg
will state that it is too early.

I've looked at the OnTime code, but it will not serve my purpose.
Any ideas would be greatly appreciated.

Thanks,

WA



All times are GMT +1. The time now is 10:08 AM.

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