Randbetween and Index but exclude a value

Thomo4321

New Member
Joined
Apr 18, 2019
Messages
44
Office Version
  1. 2016
Platform
  1. Windows
Morning,

Im after a solution to exclude a value (NSTK) from being selected for the following, if there is anything that can be improved in it, that would also be awesome, such as not having to specify a range for RANDBETWEEN(1,ROWS($A$2:$A$2295)).

=INDEX(Table_PARTS_BY_BIN_LOCATION_Data,RANDBETWEEN(1,ROWS($A$2:$A$2295)),1)

1684805277409.png


1684805324960.png


1684805224257.png
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
Thanks Mate,

2016 version and on Windows
 
Upvote 0
Thanks for that. (y)

Rather than specifying a range you could use
Excel Formula:
=INDEX(Table_PARTS_BY_BIN_LOCATION_Data,RANDBETWEEN(1,ROWS(Table_PARTS_BY_BIN_LOCATION_Data)),1)

If you are happy with a helper column you could use
Excel Formula:
=IF([@[Bin1-L]]="NSTK","",RAND())
in the Table_PARTS_BY_BIN_LOCATION_Data table (I called it Rnd) and then use
Excel Formula:
=INDEX(Table_PARTS_BY_BIN_LOCATION_Data[Part'#],AGGREGATE(15,6,(ROW(Table_PARTS_BY_BIN_LOCATION_Data)-ROW(Table_PARTS_BY_BIN_LOCATION_Data[#Headers]))/(Table_PARTS_BY_BIN_LOCATION_Data[Rnd]=SMALL(Table_PARTS_BY_BIN_LOCATION_Data[Rnd],ROWS(A$2:A2))),1))
 
Last edited:
Upvote 0
I have tried the last formula, it comes up with an error

1685339399924.png


I could be special though haha, Also where would this helper column go?
 
Upvote 0
The formula for the helper column is the 2nd one I posted not the last one.
 
Upvote 0

Forum statistics

Threads
1,215,453
Messages
6,124,930
Members
449,195
Latest member
Stevenciu

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