# random generation of whole numbers without duplication

##### New Member
Hi,

I would like to randomly generate 10 numbers between 1-750, without duplication. Thanks for any help you are able to lend.

### Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

#### GorD

##### Well-known Member
Try this code that I saved for future reference a while back - not written by me. It was written By DRJ aka Jacob

Is Jacob still around the board these days?

Code:
``````Option Explicit

Sub RandomNumber()

Dim Lowest              As Long
Dim Highest             As Long
Dim x                   As Long
Dim y                   As Long
Dim Total               As Long
Dim ChoiceTemp          As Long
Dim Choice()            As Long
Dim Repeat              As Boolean

Application.ScreenUpdating = False

Lowest = 1
Highest = InputBox("what is the highest number?")
Total = InputBox("How many combinations do you want")

ReDim Choice(1 To Total)

For x = 1 To Total
a:
Randomize
Repeat = False
ChoiceTemp = Int((Highest + 1 - Lowest) * Rnd + Lowest)
For y = 1 To Total
If Choice(y) = ChoiceTemp Then
Repeat = True
Else
End If
Next y
If Repeat = True Then
GoTo a:
Else
Choice(x) = ChoiceTemp
End If
Next x
For x = 1 To Total
Sheets("Sheet1").Range("A" & x).Value = Choice(x)
Next

End Sub``````

Replies
4
Views
187
Replies
0
Views
75
Replies
41
Views
1K
Replies
2
Views
275
Replies
0
Views
122

1,195,748
Messages
6,011,426
Members
441,614
Latest member
TiaGtz

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back