
Originally Posted by
daddylonglegs
I don't think you'll get this to work with that approach using INDEX. You could probably use a similar approach with CHOOSE, i.e
=CHOOSE(INT(RAND()*COUNTA(B9,B13,B15,B16,B17,B20,B21,B23,B25,B31,B33,B34,B35,B37,B38,B39,B41,B42,B44,B45,B47,B50,B51,B52))+1,B9,B13,B15,B16,B17,B20,B21,B23,B25,B31,B33,B34,B35,B37,B38,B39,B41,B42,B44,B45,B47,B50,B51,B52)
but CHOOSE limits you to 29 arguments.
I'd suggest using a helper column, e.g. in D9:D66 put either "B" or "G" to indicate boy or girl on each row (you can hide this column if you want) then you can use this formula to generate a random "B" number from column B
=INDEX(B9:B66,SMALL(IF(D9:D66="B",ROW(D9:D66)-ROW(D9)+1),INT(RAND()*COUNTIF(D9:D66,"B")+1)))
This is an "array formula" that needs to be confirmed with CTRL+SHIFT+ENTER. To do this select the cell with formula, press F2 key then hold down CTRL and SHIFT keys and press ENTER so that curly braces like { and } appear around the formula in the formula bar.
Note: I've used RAND() rather than RANDBETWEEN to avoid ATP functions.....but you could also use RANDBETWEEN.....
Note2: I don't know if you expect any cells to be blank in B9:B66. If there are then CHOOSE approach won't work correctly unless those blanks are progressively from the bottom of the range
Bookmarks