Pick random rows from table

eaxlns

New Member
Joined
Apr 18, 2019
Messages
15
Office Version
  1. 365
Platform
  1. MacOS
Hello,
I would like to set up a formula so that it returns random rows from the below table.
I would need to return the corresponding columns as well, for example if it returns the value in A4 it would need to return the corresponding value in B4, C4 and D4 as well.

[TABLE="width: 500"]
<tbody>[TR]
[TD]Card Code[/TD]
[TD]Rarity[/TD]
[TD]Colour[/TD]
[TD]Quantity[/TD]
[/TR]
[TR]
[TD]610BK
[/TD]
[TD][TABLE="width: 78"]
<tbody>[TR]
[TD="width: 78"]Common[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]Blue
[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]610BK[/TD]
[TD][TABLE="width: 78"]
<tbody>[TR]
[TD="width: 78"]Uncommon[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]Red[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]610BK[/TD]
[TD][TABLE="width: 78"]
<tbody>[TR]
[TD="width: 78"]Legendary[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]Silver[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]139WH[/TD]
[TD]Common[/TD]
[TD]Blue[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]139WH[/TD]
[TD]Uncommon[/TD]
[TD]Red[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD][TABLE="width: 70"]
<tbody>[TR]
[TD="width: 70"]PL637[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]Legendary[/TD]
[TD]Gold[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD][TABLE="width: 70"]
<tbody>[TR]
[TD="width: 70"]PL637[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]Common[/TD]
[TD]Red[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD][TABLE="width: 70"]
<tbody>[TR]
[TD="width: 70"]930PL[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]Uncommon[/TD]
[TD]Blue[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD][TABLE="width: 70"]
<tbody>[TR]
[TD="width: 70"]930PL[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]Legendary[/TD]
[TD]Silver[/TD]
[TD]1[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Is this the sort of thing you mean.
Formula in F2 is stand-alone
Formula in G2 is copied across to column J
To get a new random row, just press F9

Excel Workbook
ABCDEFGHIJ
1Card CodeRarityColourQuantityIndexCard CodeRarityColourQuantity
2610BKCommonBlue23610BKLegendarySilver3
3610BKUncommonRed1
4610BKLegendarySilver3
5139WHCommonBlue1
6139WHUncommonRed2
7PL637LegendaryGold1
8PL637CommonRed3
9930PLUncommonBlue2
10930PLLegendarySilver1
11
Random Row
 
Last edited:
Upvote 0
That's great, thanks.
Is it possible to do Cell F2 without putting the number of rows in the formula, so instead of A2:A10, could we do A:A?
My data set varies on an hourly basis so it would save me some time to not have to change this number every time.
 
Upvote 0
Assuming there are no blank rows within your data, try this in F2

=RANDBETWEEN(1,COUNTA(A:A)-1)
 
Upvote 0
Yes, that works, thanks.
Taking this one step further, could the random value in column F be one which has not appeared in the previous row?
 
Upvote 0
Taking this one step further, could the random value in column F be one which has not appeared in the previous row?
That is considerably trickier, but try this.
F2 is copied down as far as you might ever need.
G2 is copied across to J and down as far as the column F formula.

Excel Workbook
ABCDEFGHIJ
1Card CodeRarityColourQuantityIndexCard CodeRarityColourQuantity
2610BKCommonBlue26139WHUncommonRed2
3610BKUncommonRed19930PLUncommonBlue2
4610BKLegendarySilver310930PLLegendarySilver1
5139WHCommonBlue18PL637CommonRed3
6139WHUncommonRed23610BKUncommonRed1
7PL637LegendaryGold17PL637LegendaryGold1
8PL637CommonRed35139WHCommonBlue1
9930PLUncommonBlue22610BKCommonBlue2
10930PLLegendarySilver14610BKLegendarySilver3
11
Random Row
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,205
Members
452,618
Latest member
Tam84

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