Re: Nine random and unlike numbers
- From: "Karoo News" <neil.null@xxxxxxxxxx>
- Date: Sun, 29 Jan 2006 17:02:40 -0000
Try this it works but some on here may think its a bit poor?
Sub randNumber()
Range("A1").Value = Int((9 * Rnd) + 1)
For i = 1 To 8
rng = "A" & i
Redo:
Range("A1").Offset(i, 0).Value = Int((9 * Rnd) + 1)
For n = 0 To i - 1 Step 1
If Range("A1").Offset(i, 0).Value = Range("A1").Offset(n, 0) Then
n = n - 1
GoTo Redo
End If
Next n
Next i
End Sub
This puts a random number in cell A1 then starts a loop from A2 which first
starts by entering the next random number in A2 using offset then checks it
against A1 if it matches it enters another rand number until it finds one
that does not match. And then so on in the loop with the next cell.
Regards
Neil
"Roy" <Roy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:73A5E630-1542-4464-8B6B-09D7C9862F94@xxxxxxxxxxxxxxxx
> Hi,
>
> How can I generate 9 diffrent numbers from 1 to 9 thats not repeat it's
> self.
> I need the number 1 - 9 in random order.
>
.
- Prev by Date: Re: Nine random and unlike numbers
- Next by Date: Re: How do I hide 5 command buttons
- Previous by thread: Re: Nine random and unlike numbers
- Next by thread: Combining name ranges to create database. Pivot? Consolidate? I've tried and I'm stuck!
- Index(es):