Maybe:
LET(M,25,A,FILTER(BP8:EP8,BP8:EP8>0),B,AI$7:AI7,C,COUNTIF(B,A),D,FILTER(A,B<M),E,INT(RAND()*COLUMNS(D)+1),IFERROR(INDEX(D,E),"NO BPA"))
"D" will be smaller than "A", so you might get an index that goes too big. But it should work some of the time (most of the time). If it never works, that is troubling.
What I like about "LET" is that you can diagnose it pretty well. change it to:
LET(M,25,A,FILTER(BP8:EP8,BP8:EP8>0),B,AI$7:AI7,C,COUNTIF(B,A),D,FILTER(A,B<M),E,INT(RAND()*COLUMNS(D)+1),F,IFERROR(INDEX(D,E),"NO BPA"),F)
And then replace that last "F" with all the other variables until the problem becomes obvious.