Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 440
Default 'Flash' random numbers

Is it possible to have numbers from a predetermined list, appear in a
specified cell at a specified time interval?
IE from a list in (A1:A30) containing numbers from 1-30, I would like a
random number to appear in F10 every 4 seconds.
What do you think?
--
Traa Dy Liooar

Jock
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default 'Flash' random numbers

Enter this VBA:

Public whn As Double
Public Const T = 4 ' four seconds
Public Const mac = "flash" ' the name of the procedure to run

Sub StartTimer()
whn = Now + TimeSerial(0, 0, T)
Application.OnTime EarliestTime:=whn, Procedu=mac, Schedule:=True
End Sub

Sub StopTimer()
On Error Resume Next
Application.OnTime EarliestTime:=whn, Procedu=mac, Schedule:=False
End Sub

Sub flash()
n = Evaluate("=randbetween(1,30)")
Range("F10").Value = Cells(n, 1).Value
Call StartTimer
End Sub

Start by running StartTimer.
--
Gary''s Student - gsnu200773


"Jock" wrote:

Is it possible to have numbers from a predetermined list, appear in a
specified cell at a specified time interval?
IE from a list in (A1:A30) containing numbers from 1-30, I would like a
random number to appear in F10 every 4 seconds.
What do you think?
--
Traa Dy Liooar

Jock

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 440
Default 'Flash' random numbers

Nearly there!
I have placed the subs in sheet1 and public constants in module1.
When I run Start timer' a number appears in F10 then, after about 4 secs, I
get the message "The macro '!flash' cannot be found"
What have I done wrong here?
--
Traa Dy Liooar

Jock


"Gary''s Student" wrote:

Enter this VBA:

Public whn As Double
Public Const T = 4 ' four seconds
Public Const mac = "flash" ' the name of the procedure to run

Sub StartTimer()
whn = Now + TimeSerial(0, 0, T)
Application.OnTime EarliestTime:=whn, Procedu=mac, Schedule:=True
End Sub

Sub StopTimer()
On Error Resume Next
Application.OnTime EarliestTime:=whn, Procedu=mac, Schedule:=False
End Sub

Sub flash()
n = Evaluate("=randbetween(1,30)")
Range("F10").Value = Cells(n, 1).Value
Call StartTimer
End Sub

Start by running StartTimer.
--
Gary''s Student - gsnu200773


"Jock" wrote:

Is it possible to have numbers from a predetermined list, appear in a
specified cell at a specified time interval?
IE from a list in (A1:A30) containing numbers from 1-30, I would like a
random number to appear in F10 every 4 seconds.
What do you think?
--
Traa Dy Liooar

Jock

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 440
Default 'Flash' random numbers

OK, ignore last as I've got it working. However.......
a number doesn't appear every time, sometimes the cell is blank for a couple
of changes before a number will appear. Odd
Also, would it be possible to show data from a list rather than numbers?
Thanks very much.
--
Traa Dy Liooar

Jock


"Jock" wrote:

Nearly there!
I have placed the subs in sheet1 and public constants in module1.
When I run Start timer' a number appears in F10 then, after about 4 secs, I
get the message "The macro '!flash' cannot be found"
What have I done wrong here?
--
Traa Dy Liooar

Jock


"Gary''s Student" wrote:

Enter this VBA:

Public whn As Double
Public Const T = 4 ' four seconds
Public Const mac = "flash" ' the name of the procedure to run

Sub StartTimer()
whn = Now + TimeSerial(0, 0, T)
Application.OnTime EarliestTime:=whn, Procedu=mac, Schedule:=True
End Sub

Sub StopTimer()
On Error Resume Next
Application.OnTime EarliestTime:=whn, Procedu=mac, Schedule:=False
End Sub

Sub flash()
n = Evaluate("=randbetween(1,30)")
Range("F10").Value = Cells(n, 1).Value
Call StartTimer
End Sub

Start by running StartTimer.
--
Gary''s Student - gsnu200773


"Jock" wrote:

Is it possible to have numbers from a predetermined list, appear in a
specified cell at a specified time interval?
IE from a list in (A1:A30) containing numbers from 1-30, I would like a
random number to appear in F10 every 4 seconds.
What do you think?
--
Traa Dy Liooar

Jock

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 440
Default 'Flash' random numbers

Ok, engage brain before typing........
Sorted! Thanks Gary''s Student
--
Traa Dy Liooar

Jock


"Jock" wrote:

OK, ignore last as I've got it working. However.......
a number doesn't appear every time, sometimes the cell is blank for a couple
of changes before a number will appear. Odd
Also, would it be possible to show data from a list rather than numbers?
Thanks very much.
--
Traa Dy Liooar

Jock


"Jock" wrote:

Nearly there!
I have placed the subs in sheet1 and public constants in module1.
When I run Start timer' a number appears in F10 then, after about 4 secs, I
get the message "The macro '!flash' cannot be found"
What have I done wrong here?
--
Traa Dy Liooar

Jock


"Gary''s Student" wrote:

Enter this VBA:

Public whn As Double
Public Const T = 4 ' four seconds
Public Const mac = "flash" ' the name of the procedure to run

Sub StartTimer()
whn = Now + TimeSerial(0, 0, T)
Application.OnTime EarliestTime:=whn, Procedu=mac, Schedule:=True
End Sub

Sub StopTimer()
On Error Resume Next
Application.OnTime EarliestTime:=whn, Procedu=mac, Schedule:=False
End Sub

Sub flash()
n = Evaluate("=randbetween(1,30)")
Range("F10").Value = Cells(n, 1).Value
Call StartTimer
End Sub

Start by running StartTimer.
--
Gary''s Student - gsnu200773


"Jock" wrote:

Is it possible to have numbers from a predetermined list, appear in a
specified cell at a specified time interval?
IE from a list in (A1:A30) containing numbers from 1-30, I would like a
random number to appear in F10 every 4 seconds.
What do you think?
--
Traa Dy Liooar

Jock



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default 'Flash' random numbers

There are two separate thing to check:

A. Make sure the stuff I posted is pasted in a standard module, not a
Private area:

From an Excel worksheet:
1. ALT-F11 brings up the VBE window
2. ALT-I
ALT-M opens a fresh module
3. paste the stuff in and close the VBE window


If you have more than one workbook open at the same time, Excel may have
trouble finding flash. If this is the case change:

Sub Flash()
to:
Public Sub flash()
--
Gary''s Student - gsnu200773


"Jock" wrote:

Nearly there!
I have placed the subs in sheet1 and public constants in module1.
When I run Start timer' a number appears in F10 then, after about 4 secs, I
get the message "The macro '!flash' cannot be found"
What have I done wrong here?
--
Traa Dy Liooar

Jock


"Gary''s Student" wrote:

Enter this VBA:

Public whn As Double
Public Const T = 4 ' four seconds
Public Const mac = "flash" ' the name of the procedure to run

Sub StartTimer()
whn = Now + TimeSerial(0, 0, T)
Application.OnTime EarliestTime:=whn, Procedu=mac, Schedule:=True
End Sub

Sub StopTimer()
On Error Resume Next
Application.OnTime EarliestTime:=whn, Procedu=mac, Schedule:=False
End Sub

Sub flash()
n = Evaluate("=randbetween(1,30)")
Range("F10").Value = Cells(n, 1).Value
Call StartTimer
End Sub

Start by running StartTimer.
--
Gary''s Student - gsnu200773


"Jock" wrote:

Is it possible to have numbers from a predetermined list, appear in a
specified cell at a specified time interval?
IE from a list in (A1:A30) containing numbers from 1-30, I would like a
random number to appear in F10 every 4 seconds.
What do you think?
--
Traa Dy Liooar

Jock

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 698
Default 'Flash' random numbers

Hi Jock,
Try this, in the sheets VB editor. In A1 enter =RANDBETWEEN(1,30) AND IN
F10 enter =A1.
Run the sub FourSec()

Option Explicit

Sub FourSec()
Dim Myseconds
Myseconds = 4
Call MyPause(Myseconds)
End Sub

Sub MyPause(Myseconds)
Dim MyTime
'1/86400 = 0.0000115740740740741 = 1 second (fraction of a day)
MyTime = Time
Do Until Time = MyTime + (1 / 86400 * Myseconds)
If Time < MyTime Then Exit Do 'For after midnight
Loop
Calculate
Call FourSec
'MsgBox "We paused for 4 seconds!"

End Sub

HTH
Regards,
Howard

"Jock" wrote in message
...
Is it possible to have numbers from a predetermined list, appear in a
specified cell at a specified time interval?
IE from a list in (A1:A30) containing numbers from 1-30, I would like a
random number to appear in F10 every 4 seconds.
What do you think?
--
Traa Dy Liooar

Jock



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
getting numbers divisible by 4 from random numbers in ascending order ramana Excel Worksheet Functions 6 June 19th 07 06:41 PM
How to select top six numbers from a of range of random numbers Jack M Taylor Excel Worksheet Functions 4 January 30th 07 09:18 PM
Can Excel pick random numbers from 1-300 and not repeat numbers? Julian Excel Discussion (Misc queries) 1 June 7th 06 07:17 AM
Non-random numbers generated by excel's data analysis random gener Allie Excel Worksheet Functions 10 September 17th 05 06:19 AM
Non-random numbers generated by excel's data analysis random gener Harlan Grove Excel Discussion (Misc queries) 2 September 13th 05 04:06 PM


All times are GMT +1. The time now is 08:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"