Thread: Random time?
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
joeu2004[_2_] joeu2004[_2_] is offline
external usenet poster
 
Posts: 829
Default Random time?

"slipper" wrote:
Ok thanks mate for your input and taking the time to reply
in length to my query. Back to the drawing board i guess.
I will try and think of some other way to implement what i need.


Download https://app.box.com/s/g14vbenkl79uv4s3llym and see if that gets you
started.

Note: Ignore any preview errors and simply download the file. box.net
preview is limited.

I hope the comments in the textbox in Sheet1 are somewhat self-explanatory.

I tried to guess what you might be trying to do. At least, it has similar
elements: select a message randomly; select a random timeout for some
messages; display those as black until the timeout elapses.

I tried to mimick how I thought you might implement that functionality. It
is not the way I would do it. I would rely more VBA code.

I also implemented a countdown cell. If you do not want that, I'll tell you
how to eliminate it.

My timeout is in seconds, not minutes. I don't have the patience to wait
more than a few seconds. Simply change TimeSerial(0,0,1) to
TimeSerial(0,x,0).

After downloading and opening the Excel file, press alt-F11 to open the VBA
window and study the VBA procedures. You should see the Project Explorer
pane on the left. If not, press ctrl+R to open the Project Explorer pane.

Double-click on Sheet1 to see the Worksheet_Change event procedure. That
schedules the "countdown" procedure, if conditions are right. (See comments
in the VBA code.)

If you do not want the countdown cell, change TimeSerial(0,0,1) to
TimeSerial(0,0,x), and eliminate the statement.

Double-click on Module1 to see the procedure "countdown", as well as the
function myRandBetween.

If you do not want the countdown cell, change the statement x = x-1 to
simply x = 0. That is in addition to the change in Worksheet_Change, noted
above.

Those are minimal changes. Of course, there are more efficient
modifications that you could make.

Hope that helps.