How display random unique numbers from a list in column

arthurklein43

New Member
Joined
Aug 3, 2018
Messages
15
Hello again
I wasted all day trying to resolve this problem without help but unfortunately unsuccessful. :confused: so here I am asking for help the great helpful community here.
I have a column A with 10K numbers in ascending order and could be even more . I need to pick 500 random unique numbers from that column and display them in separate column. order doesnt matter . just need to be random unique and mixed so i guess they shouldn be in any order just mixed.
here is what i tried so far
I found a post from Eric W post #2 here https://www.mrexcel.com/forum/excel-questions/937500-vba-unique-random-numbers-list.html?highlight=pick+random+numbers+column
Sheet2

Array Formulas
CellFormula
H8{=LARGE(IF((COUNTIF($H$7:H7, $E$8:$E$100)=0)*($E$8:$E$100<>""),$E$8:$E$100), RANDBETWEEN(1,SUM(IF((COUNTIF($H$7:H7, $E$8:$E$100)=0)*($E$8:$E$100),1))))}

<tbody>
</tbody>

Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself
EFGHIJ
7Random selection
8122
9218
10321
11410
12514
1364
1479
1582
16913
171015
1811
1912
2013
2114
2215
2316
2417
2518
2619
2720
2821
2922
30

<tbody>
</tbody>
I used the formula in H8 and it works great but the problem is it is good for 20-30-50 numbers but for more than that slows down the excel.It takes a while to do the calculation. also the other problem was that if i do anything in worksheet like add a number in different cell or even just copy or paste something it refresh the whole worksheet and the formulas start recalculating and change the numbers again and recalculating takes a while . even if I use another worksheet it still recalculating. I need them if possible to stay still so i can work with them.
So practically I need a simple formula that will not slow down the calculation when in use with large amount of numbers. numbers are 12-13 digits each.
I think I covered everything. Thanks everyone for your help
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
If you are willing to try a macro, this should be quite fast...
Code:
[table="width: 500"]
[tr]
	[td]Sub Get500UniqueRandomNumbers()
  Dim Cnt As Long, RI As Long, HowManyNums As Long, Tmp As Variant, Nums As Variant
  Randomize
  HowManyNums = 500
  Nums = Range("E8", Cells(Rows.Count, "E").End(xlUp))
  For Cnt = UBound(Nums) To 1 Step -1
    RI = Int(Cnt) * Rnd + 1
    Tmp = Nums(RI, 1)
    Nums(RI, 1) = Nums(Cnt, 1)
    Nums(Cnt, 1) = Tmp
  Next
  Range("H8:H" & Rows.Count).Clear
  Range("H8").Resize(HowManyNums) = Nums
End Sub[/td]
[/tr]
[/table]
The above macro assumes your number pool (the 10K plus numbers you want to randomize) starts in cell E8 (the code will figure out how many numbers are in the pool on its own) and the 500 numbers you want are outputted starting in cell H8.

HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (Get500UniqueRandomNumbers) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for. If you will need to do this again in this same workbook, and if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "Yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,614
Members
449,090
Latest member
vivek chauhan

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