# Random Data with No Blanks and No Duplicates

##### New Member
I am looking for a way to pull a random piece of data from a table, and skip the blanks and ensure there are no duplicates. The farthest I have gotten is by using <=INDEX('Sheet 1'!E8:G68,RANDBETWEEN(1,ROWS('Sheet 1'!E8:G68)),1), but this formula pulls the empty boxes. Not sure if this will pull duplicates, I haven't seen any yet. Thanks in advance!

### Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

#### jasonb75

##### Well-known Member
Not something that I've tried (I don't personally have office 365 to test the filter function) but one that comes to mind

=INDEX(FILTER('Sheet 1'!\$E\$8:\$E\$68,'Sheet 1'!\$E\$8:\$E\$68<>""),RANDBETWEEN(1,COUNTIF('Sheet 1'!\$E\$8:\$E\$68,"?*")))

You might need to enter it as a legacy array by using Ctrl Shift Enter to prevent it from trying to spill.

##### Well-known Member

Your formula should work though you'll need to add a randomization for columns also, e.g.
=INDEX(\$E\$8:\$G\$68,RANDBETWEEN(1,ROWS(\$E\$8:\$E\$68)),RANDBETWEEN(1,COLUMNS(\$E\$8:\$G\$8)))

Yes, this will produce duplicates. Approximately 50% of the time you'll get a duplicate by the 10th execution.

I can only think of a kludgy way of addressing this with multiple work columns, I've only got Excel 2016, so probably @jasonb75 has the better approach.

Replies
0
Views
192
Replies
3
Views
88
Replies
1
Views
163
Replies
6
Views
91
Replies
2
Views
116

1,126,888
Messages
5,621,434
Members
415,839
Latest member
faraji

### 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.

### Which adblocker are you using?

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

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