Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Pause for thought!

Col A1=0, A2=2 etc down to A91=90

Col B1=RAND() etc down to B91=RAND()

D1=INDEX($A$2:$A$92,RANK(B2,$B$2:$B$92))

I press F9 until 0(zero) appears (in D1) then:

I press F9 (once) and a single random number (1-90) appears (in D1)

A normal, commercial, random selector (when pressing the start button)
visually revolves through all numbers (for several seconds) before stopping,
having selected a number.

Question: What do I need to add to D1 (above) to make it do the same?

I know it can be done, but it has got me beaten. Please advise.

--
Regards,
John
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default Pause for thought!

What you appear to want is a random number between 0 and 91, assuming you
meant A2=1 (not 2 as in your post); otherwise A91 would not equal 90.

In Excel 2007 you could use...

=RANDBETWEEN(0,91)

In earlier versions use

=INT(RAND()*(92))

If you want numbers to 'roll' around for some visual effect then you need
some VBA code to control the output. Excel does not have this function built
in. Try something like...and assign this macro SpinNumber to a worksheet
control.

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub SpinNumber()
Dim iX As Integer
For iX = 1 To 200
Range("D1") = Int(92 * Rnd)
Sleep 10
Next
End Sub

--

Regards,
Nigel




"JOHN BERNARD" wrote in message
...
Col A1=0, A2=2 etc down to A91=90

Col B1=RAND() etc down to B91=RAND()

D1=INDEX($A$2:$A$92,RANK(B2,$B$2:$B$92))

I press F9 until 0(zero) appears (in D1) then:

I press F9 (once) and a single random number (1-90) appears (in D1)

A normal, commercial, random selector (when pressing the start button)
visually revolves through all numbers (for several seconds) before
stopping,
having selected a number.

Question: What do I need to add to D1 (above) to make it do the same?

I know it can be done, but it has got me beaten. Please advise.

--
Regards,
John


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Pause for thought!

Thanks Nigel. Yes - A2 = 1.

Not sure about the 'roll' around macro, but will give it a try.
Much appreciated
--
Regards,
John


"Nigel" wrote:

What you appear to want is a random number between 0 and 91, assuming you
meant A2=1 (not 2 as in your post); otherwise A91 would not equal 90.

In Excel 2007 you could use...

=RANDBETWEEN(0,91)

In earlier versions use

=INT(RAND()*(92))

If you want numbers to 'roll' around for some visual effect then you need
some VBA code to control the output. Excel does not have this function built
in. Try something like...and assign this macro SpinNumber to a worksheet
control.

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub SpinNumber()
Dim iX As Integer
For iX = 1 To 200
Range("D1") = Int(92 * Rnd)
Sleep 10
Next
End Sub

--

Regards,
Nigel




"JOHN BERNARD" wrote in message
...
Col A1=0, A2=2 etc down to A91=90

Col B1=RAND() etc down to B91=RAND()

D1=INDEX($A$2:$A$92,RANK(B2,$B$2:$B$92))

I press F9 until 0(zero) appears (in D1) then:

I press F9 (once) and a single random number (1-90) appears (in D1)

A normal, commercial, random selector (when pressing the start button)
visually revolves through all numbers (for several seconds) before
stopping,
having selected a number.

Question: What do I need to add to D1 (above) to make it do the same?

I know it can be done, but it has got me beaten. Please advise.

--
Regards,
John



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
harder than i thought Tomkat743 Excel Discussion (Misc queries) 2 March 9th 09 02:37 PM
Stop / Pause a Macro using Pause button scott56hannah Excel Programming 0 June 27th 08 12:48 PM
Don't think it's possible, but I thought I would ask. smaumau Excel Worksheet Functions 1 April 3rd 06 11:20 PM
On second thought ... Jerry Kinder New Users to Excel 0 November 26th 04 02:38 AM
thought process Robert Couchman[_4_] Excel Programming 3 March 1st 04 04:20 PM


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

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

About Us

"It's about Microsoft Excel"