Random Numbers (up to a max value) with no Duplicates - Draw Generator

Simon2001

New Member
Joined
Jun 28, 2019
Messages
16
Office Version
  1. 365
Platform
  1. Windows
Hello

This old post is quite frankly brilliant and exactly what I needed to create. I have been using a random generator but couldn't figure out how to avoid duplicates.


I've got it working perfect and I'm now trying to figure out how to make the range dynamic so rather than a fixed 90 rows/numbers, I want to be able to enter a value in a cell for maximum number of entries so 16, 32, whatever, etc)

Sub StartOver()
ActiveSheet.UsedRange.Clear
Range("E1") = "Number"
Range("F1") = "Sort"
Range("E2") = 1
Range("E2:E17").DataSeries Step:=1
Range("F2:F17").Formula = "=Rand()"
End Sub

Sub DrawUnique()
Range("F1").CurrentRegion.Sort Key1:=Range("F1"), Header:=xlYes
Range("E100").End(xlUp).Copy Destination:=Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
Range("E100").End(xlUp).Resize(1, 2).Clear
End Sub

Can anyone suggest a way to alter this code to do this?

Thanks
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,124
Members
453,021
Latest member
Justyna P

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top