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

"slipper" wrote:
The line of code you posted
=NOW() + TIME(0,RANDBETWEEN(0,15),0)
would that work in conditional formatting as a new rule?


NOW()+TIME(...) simply computes a number, a future date&time. It does not
cause an event to take place at the future time.

You might calculate the future date&time in some cell (X1). (How to do that
is another matter.) Then for the cell with the hidden message, you might
have the conditional formats:

=NOW()=X1
and
=NOW()<X1

each specifying an appropriate cell font and/or fill color.

However, NOW() is not recalculated automagically. Excel does not
re-evaluate NOW() every second, for example. So unless there is a
recalculation at the date&time in X1, the cell format will not change then.

Moreover, there is the matter of how the future date&time is entered into
X1. You cannot simply use NOW()+TIME(...) because NOW() changes
dynamically. It is the current time, after all. Also, RANDBETWEEN()
changes dynamically, as well. It is recalculated every time there is a
recalculation cycle; for example, every time any cell in any worksheet in
the workbook is edited.

So you would have to use VBA code either to effectively compute
NOW()+TIME(...) or to enable the recalculation of X1, if X1 is on a
worksheet for which calculation is normally disabled.

And since VBA is needed anyway, I would forego any attempt to make
conditional formatting work for this purpose. Instead, I would use VBA to
implement all of the needed functionality: perhaps an event procedure and
one or two procedures that are executed using Application.OnTime.


"slipper" wrote:
for several of the messages i want them hidden from the user
for a random time (0-15 minutes).

I can hide the message from the user by originally filling the
cell black which effectivley hides the message, the problem is
how to clear this formatting after the random time has elapsed.


This is very complicated and difficult to do correctly. It is difficult to
cover and handle all contingencies.

In addition to the problem of revealing the hidden, there is the question
of: once revealed, must the cell fill format be restored to black (hidden)
again? If so, what triggers that?

There is no single "right answer". You're the inventor: you need to
specify the process and the actions precisely enough to implement.

And BTW, I do not believe setting a black background color truly hides the
message (when the foreground color is black). It is still visible in the
Formula Bar, next to "fx" under the Tool Bar, for example. Unless you have
removed the Formula Bar, and you have taken steps to prevent the user from
reinstating it.

So, I think we need to hear a lot more details about your current or
intended design before we start providing solutions.

And it might help if you provided an example Excel file that demonstrates
the intended design, as well as you can do, of course.

I think excelbanter.com provides a method for attaching files. But more
generally, upload the example Excel file to a file-sharing website, and post
the "shared" URL in a response here. The following is a list of some free
file-sharing websites; or use one of your own choice.

Box.Net: http://www.box.net/files
Dropbox: http://dropbox.com
MediaFi http://www.mediafire.com
FileFactory: http://www.filefactory.com
FileSavr: http://www.filesavr.com
RapidSha http://www.rapidshare.com
Windows Live Skydrive: http://skydrive.live.com

Unfortunately, I will not be able to help you further. This will take a lot
of work, and I do not have that kind of time.

But hopefully, my comments above are helpful by putting you on the right
path. And perhaps someone else will jump in to step you through the
implementation, once you provide all of the design details.

Good luck!