ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   RANDBETWEEN query (https://www.excelbanter.com/excel-worksheet-functions/5519-randbetween-query.html)

scottwilsonx

RANDBETWEEN query
 

Hi everyone, hope someone can help.
I have a list of 16 names, numbered 1 to 16 in the range: A1 to B17
where column A has the names, and column B the sequence from 1 to 16.

I have a cell with the formula: RANDBETWEEN(1,16) which gives you a
number between 1 and 16 each time you press F9 to recalculate.

However, I would like to change the formulae so that if you recalculate
and get the number 6 (for example), you won't get 6 again until the
other 15 numbers have also been shown.

Is this possible using a function or VBA ?

Many thanks for your help!


--
scottwilsonx
------------------------------------------------------------------------
scottwilsonx's Profile: http://www.excelforum.com/member.php...o&userid=11128
View this thread: http://www.excelforum.com/showthread...hreadid=274544


Frank Kabel

Hi
see:
http://www.mcgimpsey.com/excel/udfs/randint.html

--
Regards
Frank Kabel
Frankfurt, Germany

"scottwilsonx" schrieb im
Newsbeitrag ...

Hi everyone, hope someone can help.
I have a list of 16 names, numbered 1 to 16 in the range: A1 to B17
where column A has the names, and column B the sequence from 1 to 16.

I have a cell with the formula: RANDBETWEEN(1,16) which gives you a
number between 1 and 16 each time you press F9 to recalculate.

However, I would like to change the formulae so that if you

recalculate
and get the number 6 (for example), you won't get 6 again until the
other 15 numbers have also been shown.

Is this possible using a function or VBA ?

Many thanks for your help!


--
scottwilsonx
---------------------------------------------------------------------

---
scottwilsonx's Profile:

http://www.excelforum.com/member.php...o&userid=11128
View this thread:

http://www.excelforum.com/showthread...hreadid=274544



hgrove


Frank Kabel wrote...
see:
http://www.mcgimpsey.com/excel/udfs/randint.html

...

Incomplete answer. Randint could provide a shuffled array of numbers
from 1 to 16, but to sample from it cyclically would require another
UDF like

Function cycrnd() As Long
Static a As Variant, n As Long

Application.Volatile 'necessary for this

If IsEmpty(a) Then
a = randint(1, 16)
n = LBound(a)

Else
If n < UBound(a) Then n = n + 1 Else n = LBound(a)

End If

cycrnd = a(n)

End Function


--
hgrove
------------------------------------------------------------------------
hgrove's Profile: http://www.excelforum.com/member.php...o&userid=11432
View this thread: http://www.excelforum.com/showthread...hreadid=274544



All times are GMT +1. The time now is 12:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com