Divide a number into multiple results

excelNewbie22

Well-known Member
Joined
Aug 4, 2021
Messages
531
Office Version
  1. 365
Platform
  1. Windows
hi!

i have a dynamic range of number, every few days changes,
a2:a1000, or a2:a1515....
and i want to get random x numbers which will cover most of the range,
by getting the entire count of the range, say... 950, divides to say... 15, which will be 63 (round),
so i'll get 1 random number from each 62 cells,
so i did this:
sheet1
ABCDEFGH
1950divide to 15vstack
2163so…163224
326412600
43127189
54190252
65
76
87
98
109
1110
1211
1312
1413
1514
1615
1716
1817
1918
2019
2120
2221
2322
2423
2524
2625
2726
2827
2928
3029
3130
3231
3332
sheet1
Cell Formulas
RangeFormula
B2B2=ROUND(950/15,0)
H2:H3H2=VSTACK(TRANSPOSE(LET(u,UNIQUE(TOROW(A2:INDIRECT("a"&$B$2+2)),1),TAKE(SORTBY(u,RANDARRAY(,COLUMNS(u))),,1))),TRANSPOSE(LET(u,UNIQUE(TOROW(INDIRECT("a"&$B$2+3):INDIRECT("a"&$B$2*2+(2))),1),TAKE(SORTBY(u,RANDARRAY(,COLUMNS(u))),,1))))
G2G2=TRANSPOSE(LET(u,UNIQUE(TOROW(A2:INDIRECT("a"&$B$2+2)),1),TAKE(SORTBY(u,RANDARRAY(,COLUMNS(u))),,1)))
G3G3=TRANSPOSE(LET(u,UNIQUE(TOROW(INDIRECT("a"&$B$2+3):INDIRECT("a"&$B$2*2+(2))),1),TAKE(SORTBY(u,RANDARRAY(,COLUMNS(u))),,1)))
Dynamic array formulas.


but this is long, is there anything more clever? shorter? (the end result will be a much longer)
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
How about
Excel Formula:
=LET(a,A2:A951,b,COUNT(a),c,FLOOR.MATH(b/15,1),DROP(REDUCE("",SEQUENCE(b/c,,,c),LAMBDA(x,y,VSTACK(x,TAKE(SORTBY(CHOOSEROWS(a,SEQUENCE(c,,y)),RANDARRAY(c)),1)))),1))
 
Upvote 0
Solution
a snag...
why the error?

sheet1
ABCDE
32123-2-3#DIV/0!
43234-3-4
54345-4-5
65456-5-6
76567-6-7
87678-7-8
98789-8-9
1098910-9-10
111091011-10-11
1211101112-11-12
1312111213-12-13
1413121314-13-14
1514131415-14-15
1615141516-15-16
1716151617-16-17
1817161718-17-18
1918171819-18-19
2019181920-19-20
2120192021-20-21
2221202122-21-22
2322212223-22-23
2423222324-23-24
2524232425-24-25
sheet1
Cell Formulas
RangeFormula
E3E3=LET(a,D3:D24,b,COUNT(a),c,FLOOR.MATH(b/15,1),DROP(REDUCE("",SEQUENCE(b/c,,,c),LAMBDA(x,y,VSTACK(x,TAKE(SORTBY(CHOOSEROWS(a,SEQUENCE(c,,y)),RANDARRAY(c)),1)))),1))
D3:D25D3=A4&"-"&B4&"-"&C4
 
Upvote 0
You get the error as col D is text & not numbers, so Count will return 0, you would need to use COUNTA
 
Upvote 0

Forum statistics

Threads
1,223,996
Messages
6,175,862
Members
452,676
Latest member
woodyp

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