How to use functions to randomly select two men and two women from excel tables?

Yesterday, I also answered a question about random selection. For reference first, the same explanation will not be repeated.

/question/9889233965566670 19

In this question, in order to increase flexibility and interest, compared with yesterday's answer, a trigger switch for re-selecting the list is added. When the data (anything) in the trigger switch is deleted, the extracted personnel list is also deleted, and when anything is input in the trigger switch, a new list is regenerated. As shown, L2 is the trigger switch.

I2=IF($L$2= ""," ",IF(OR(I3= " ",I3=0,COUNTIF(I$3:I$4,I3)& gt; 1),index($c:$c,index(small(if($b$3:$b$ 19=i$2,row($3:$ 19),4^ 10),row(indirect(" 1:"&; COUNTIF($B$3:$B$ 19,I$2)))、RANDBETWEEN( 1,COUNTIF($ B $ 3:B $ 19,I$2)))、I3))

At the same time, press Ctrl+Shift+Enter to enter the array formula, right-click J2, and then drop it down to i3: J3.