Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Create a New Random Number Every 2 Seconds
Hi, Just wondering how I can create a whole number between 1 and 10 every 2 seconds for 2 minutes on the press of a button? The number will paste in to cell A1 and be overwritten every 2 seconds when a number is generated? I'm quite new to VBA with Excel so if anyone can recommend some free easy to understand tutorials, please let me know. Thanks :) -- gatesheadthunde ------------------------------------------------------------------------ gatesheadthunde's Profile: http://www.excelforum.com/member.php...o&userid=10536 View this thread: http://www.excelforum.com/showthread...hreadid=491199 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Create a New Random Number Every 2 Seconds
One way:
Public Sub TwoRandomMinutes() Static dEnd As Double If dEnd = 0 Then dEnd = Now() + TimeSerial(0, 2, 0) If Now <= dEnd Then Range("A1").Value = Int(Rnd * 10) + 1 Application.OnTime Now() + TimeSerial(0, 0, 2), _ "TwoRandomMinutes" Else dEnd = 0 End If End Sub In article <gatesheadthunde.1zmyxb_1133902212.0529@excelfor um-nospam.com, gatesheadthunde <gatesheadthunde.1zmyxb_1133902212.0529@excelfor um-nospam.com wrote: Hi, Just wondering how I can create a whole number between 1 and 10 every 2 seconds for 2 minutes on the press of a button? The number will paste in to cell A1 and be overwritten every 2 seconds when a number is generated? I'm quite new to VBA with Excel so if anyone can recommend some free easy to understand tutorials, please let me know. Thanks :) |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Create a New Random Number Every 2 Seconds
See Chip Pearson's page on using Application.Ontime
http://www.cpearson.com/excel/ontime.htm for starting with code: http://www.mvps.org/dmcritchie/excel/getstarted.htm to generate a random number between 1 and 10 Range("B9").Value = int(rnd()*10+1) -- Regards, Tom Ogilvy "gatesheadthunde" <gatesheadthunde.1zmyxb_1133902212.0529@excelfor um-nospam.com wrote in message news:gatesheadthunde.1zmyxb_1133902212.0529@excelf orum-nospam.com... Hi, Just wondering how I can create a whole number between 1 and 10 every 2 seconds for 2 minutes on the press of a button? The number will paste in to cell A1 and be overwritten every 2 seconds when a number is generated? I'm quite new to VBA with Excel so if anyone can recommend some free easy to understand tutorials, please let me know. Thanks :) -- gatesheadthunde ------------------------------------------------------------------------ gatesheadthunde's Profile: http://www.excelforum.com/member.php...o&userid=10536 View this thread: http://www.excelforum.com/showthread...hreadid=491199 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I create a random number generator in excel? | Excel Worksheet Functions | |||
Create a Graph with Random Number Generator | Charts and Charting in Excel | |||
Can excel be used to create a random number generator? | Excel Discussion (Misc queries) | |||
Create random number bingo cards with Excel | New Users to Excel | |||
How do you create a random number generator in Excel? | Excel Worksheet Functions |