Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi everyone, I have been trying repeatedly for days now to write a macro to generat random numbers. I need to generate 23 unique numbers in 5 columns. have found a macro that can do one column at a time but i cannot modif this to work over the five columns. Here is the code for you to look at: Sub CreateRand() Dim Nums(23) Dim I As Integer Dim X As Integer Dim rng As Range Dim c As Range Dim Filled As Boolean For I = 1 To 23 Nums(I) = I Next I Set rng = Range("f1:f23") For Each c In rng Do X = Int((Rnd * 23) + 1) If Nums(X) < 0 Then c.Value = Nums(X) Nums(X) = 0 Filled = True End If Loop Until Filled Filled = False Next c End Sub All help will be greatly received!!!!!! Thanks, a slowly going bald Excel use -- davehill197 ----------------------------------------------------------------------- davehill1974's Profile: http://www.excelforum.com/member.php...fo&userid=2499 View this thread: http://www.excelforum.com/showthread.php?threadid=38521 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to keep random number from changing using RANDBETWEEN? | Excel Worksheet Functions | |||
RANDBETWEEN generating numbers outside range | Excel Worksheet Functions | |||
how can I use randbetween without repeating numbers in a set | Excel Worksheet Functions | |||
Non-random numbers generated by excel's data analysis random gener | Excel Worksheet Functions | |||
Non-random numbers generated by excel's data analysis random gener | Excel Discussion (Misc queries) |