View Single Post
  #2   Report Post  
Andrea Jones
 
Posts: n/a
Default

Here's some code that will make better random numbers for you so you don't
keep getting the same answers (you'll obviously have to declare the variables
a, b, c, etc first), it generates 5 random numbers in the range 1-50:

Randomize
Seed2 = Timer
a = (Seed2 - Int(Seed2)) + Rnd() * 50
If a 50 Then a = 50
Seed2 = Timer
b = (Seed2 - Int(Seed2)) + Rnd() * 50
If b 50 Then b = 50
While b = a
Seed2 = Timer
b = (Seed2 - Int(Seed2)) + Rnd() * 50
If b = 50 Then b = 50
Wend
Seed2 = Timer
c = (Seed2 - Int(Seed2)) + Rnd() * 50
If c 50 Then c = 50
While c = b Or c = a
Seed2 = Timer
c = (Seed2 - Int(Seed2)) + Rnd() * 50
If c 50 Then c = 50
Wend
Seed2 = Timer
d = (Seed2 - Int(Seed2)) + Rnd() * 50
If d 50 Then d = 50
While d = c Or d = b Or d = a
Seed2 = Timer
d = (Seed2 - Int(Seed2)) + Rnd() * 50
If d 50 Then d = 50
Wend
Seed2 = Timer
e = (Seed2 - Int(Seed2)) + Rnd() * 50
If e 50 Then e = 50
While e = d Or e = c Or e = b Or e = a
Seed2 = Timer
e = (Seed2 - Int(Seed2)) + Rnd() * 50
If e 50 Then e = 50
Wend
Range("A1").Select
ActiveCell.FormulaR1C1 = a
Range("A2").Select
ActiveCell.FormulaR1C1 = b
Range("A3").Select
ActiveCell.FormulaR1C1 = c
Range("A4").Select
ActiveCell.FormulaR1C1 = d
Range("A5").Select
ActiveCell.FormulaR1C1 = e

Andrea Jones
http://www.allaboutoffice.co.uk
http://www.stratatraining.co.uk
http://www.allaboutclait.com

"Mark1809" wrote:

How do I generate random lottery numbers in Excel?