Help:how to select random numbers in column

biznez

Board Regular
Joined
Nov 1, 2009
Messages
136
Hello everyone,

I have a list of numbers in A1:A50. I would like to have something that would select 10% of those numbers randomly avoiding duplicates
thanks for all your help
 
Try this:-
It now gives you 10 % of 1400, (140)

Code:
[COLOR="Navy"]Sub[/COLOR] MG19May17
[COLOR="Navy"]Dim[/COLOR] Num [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Dim[/COLOR] Pcent [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
Randomize
[COLOR="Navy"]With[/COLOR] CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
Pcent = 1400
[COLOR="Navy"]Do[/COLOR] Until .Count = Pcent * 0.1
    Num = Range("A" & Int(Rnd * Pcent) + 1).value
        [COLOR="Navy"]If[/COLOR] Not .Exists(Num) [COLOR="Navy"]Then[/COLOR]
            .Add Num, ""
        [COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Loop[/COLOR]
Sheets("Shee2").Range("A1").Resize(.Count) = Application.Transpose(.keys)
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]With[/COLOR]
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,216,114
Messages
6,128,910
Members
449,478
Latest member
Davenil

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