Random number 1 - x

CaptBrownShoes

New Member
Joined
May 16, 2024
Messages
5
Office Version
  1. 2021
Platform
  1. Windows
1715892762344.png

Here is the situation:
The table above is needing a random number that does not duplicate based on the remaining cards in deck.
The correct answer would work as follows:
  • RAND column looks at Discard Pile and if = "a" (webdings check), then "". Done!
  • Then the RAND column would look at the number of remaining cards "12" in Odds Total column as the max random number. Done!
  • Then the RAND column picks a number from 1 - 12 that does not exist in the previous attempts. NOPE!!! Can't figure this one out.
=IF([@[Discard Pile a]]="a","",RANDBETWEEN(1,tblExCards[[#Totals],[Odds]]))

I cannot get that to happen. Any suggestions?

Thus, is the a need for a VBA statement?

Thank you Team!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Try:
Book1
ABC
1OddsDiscard PileRand
28.30%9
3
48.30%7
5
68.30%10
78.30%8
8
98.30%12
10
118.30%11
12
138.30%2
14
158.30%4
168.30%6
17
188.30%5
19
2016.70%3
2116.70%1
22128
Sheet4
Cell Formulas
RangeFormula
C2:C21C2=LET( m,MAP(B2:B21,LAMBDA(m,COUNTIFS(INDEX(B2:B21,1):m,""))), IF(B2:B21="",INDEX(SORTBY(SEQUENCE(A22),RANDARRAY(A22)),IF(B2:B21="",m)),""))
A22A22=COUNTBLANK(B2:B21)
Dynamic array formulas.
 
Last edited:
Upvote 0
A little shorter.
Excel Formula:
=IF(B2:B21="",INDEX(SORTBY(SEQUENCE(A22),RANDARRAY(A22)),MAP(B2:B21,LAMBDA(m,COUNTIFS(INDEX(B2:B21,1):m,"")))),"")
 
Upvote 0
Or try this:

Book1
ABC
1OddsDiscard PileRand
20.0831
3 
40.0839
5 
60.0832
70.08310
8 
90.0837
10 
110.08311
12 
130.0833
14 
150.08312
160.0834
17 
180.0838
19 
200.1675
210.1676
2212
Sheet1
Cell Formulas
RangeFormula
C2:C21C2=IF(B2="",AGGREGATE(15,6,SEQUENCE($A$22)/(COUNTIFS($C$1:C1,SEQUENCE($A$22))=0),RANDBETWEEN(1,$A$22-COUNT($C$1:C1))),"")
A22A22=COUNT(A2:A21)
 
Upvote 0
Solution
Or try this:

Book1
ABC
1OddsDiscard PileRand
20.0831
3 
40.0839
5 
60.0832
70.08310
8 
90.0837
10 
110.08311
12 
130.0833
14 
150.08312
160.0834
17 
180.0838
19 
200.1675
210.1676
2212
Sheet1
Cell Formulas
RangeFormula
C2:C21C2=IF(B2="",AGGREGATE(15,6,SEQUENCE($A$22)/(COUNTIFS($C$1:C1,SEQUENCE($A$22))=0),RANDBETWEEN(1,$A$22-COUNT($C$1:C1))),"")
A22A22=COUNT(A2:A21)
Thank you!!!! Worked SWIMMINGLY!!!
 
Upvote 0

Forum statistics

Threads
1,217,328
Messages
6,135,912
Members
449,971
Latest member
Hughesy52

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