Enter "serial number range" in D2, 16 (i.e. total headcount) in E2, set to "recalculation and liquidation" in H2, "auxiliary column" in B5 and "serial number" in B6.
Select C5: H5 cell range, and then enter "= if ($ I $2 =" recalculate ",if (sum ($ C $4: $ H $4)).
Select the C4: H4 cell range, enter "=if($I$2=" empty", "",countif($C$5:$H$5, C5)), and then press Ctrl+enter.
Six people were randomly selected through H2. Of course, you can also insert a row of names in six rows, and directly combine the names through the index and match functions.