Putting a 30sec delay into a macro

  • Thread starter Thread starter Nick
  • Start date Start date
N

Nick

Hi All

I want to set up a spreadsheet so that it can randomly
calculate whole numbers between (and including) zero (0)
and thirty-six (36) for an imitation roulette wheel.
However, instead of just allocating the recalculate (F9)
function to a macro, I want there to be a thirty second
delay between the time of pressing the button and the
random number appearing.

The formula I have so far is "=ROUNDUP(RANDBETWEEN(-
0.9999,36),0)" but I don't know how to write a macro that
will delay the Recalculate function by thirty seconds once
I press the macro-assigned button.

Any ideas?

Cheers
Nick
 
Hi Nick
From Excel help "Wait" the following;
will re-calculate your formula after 30 second pause.

Sub Re_Calculate()
'
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 30
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
'
Calculate
End Sub

HTH

Bob C.
 
Nick

Here's another way


Application.Wait TimeValue(Now()) + TimeValue("00:00:30"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top