LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default code not working properly - VBA beginner (random numbers generation, no repeats)


I'm trying to write a code that will generate random numbers and no
number appears more than onece.



Code:
--------------------

For I = 0 To 3
For J = 0 To I
Do
n = Int(4 * Rnd) + 1 'random number generated
Array1(I) = n 'random number settled in an array
If (I = I - J) Then 'checking for the same place in array
numsOK = True
Else
If Array1(I) = Array1(I - J) Then 'comparing two different places in an array
numsOK = False
Else
numsOK = True
End If
End If

Loop Until numsOK = True
Next J 'only the last number and the first one always differ, other numbers repeat


--------------------

Next I Plz help me and tell why the program isnt working. I have no
idea, how to make it work.


--
msburza
------------------------------------------------------------------------
msburza's Profile: http://www.excelforum.com/member.php...o&userid=34222
View this thread: http://www.excelforum.com/showthread...hreadid=539800

 
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
Generate random numbers 1-100 without any repeats? ExcelFan Excel Worksheet Functions 4 May 5th 23 07:46 PM
generating random numbers without repeats Lynton Excel Discussion (Misc queries) 3 May 1st 10 03:32 PM
Random Code Generation SRK Excel Worksheet Functions 2 November 7th 08 12:13 PM
Random number generation - with no repeats Ryan Excel Discussion (Misc queries) 3 May 8th 08 03:40 PM
Random numbers generation Nishant Excel Programming 2 December 9th 05 01:50 PM


All times are GMT +1. The time now is 09:52 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"