ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   buidling randomize function that not repeating the same number (https://www.excelbanter.com/excel-programming/427014-re-buidling-randomize-function-not-repeating-same-number.html)

Mike H

buidling randomize function that not repeating the same number
 
Hi,

You posted in programming so here's a macro. Right click your sheet tab,
view code and paste the code below in and run it.

Change TopNo to the highest value you want and set the range to suit which
is currently A1 - A25. Note the TopNo must be = to the cells in the range or
they cannot be unique.

Sub Marine()
Dim TopNo As Long
TopNo = 1000
Dim FillRange As Range
Set FillRange = Range("A1:A25")
For Each C In FillRange
Do
C.Value = Int((TopNo * Rnd) + 1)
Loop Until WorksheetFunction.CountIf(FillRange, C.Value) < 2
Next
End Sub


Mike

"thread" wrote:

hi,

is there any functionality in excel that its posible to make randomize
for a certain group of number and the numbers will not return if
appeared already
example
cell1
rnd()*10=3
cell 2
rnd()*10=2
cell3
rcd()*10=3 <= this option will not appear

any idea?



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

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