почему бы и нет:
=ARRAYFORMULA(QUERY(TRANSPOSE(QUERY(TRANSPOSE(ARRAY_CONSTRAIN(SPLIT(TRANSPOSE(QUERY(
TRANSPOSE(ARRAY_CONSTRAIN(IF(IFERROR(SPLIT({"";REPT("♦"&ROW(INDIRECT("A1:A"&COUNTA(M42:M))),
ROW(INDIRECT("A1:A"&COUNTA(M42:M))))}, "♦"))<>"", , TRANSPOSE(SPLIT(REPT(
INDIRECT("M42:M"&COUNTA(M42:M)+41)&" ", COUNTA(M42:M)-5+1), " "))),
COUNTA(M42:M)-5+1, COUNTA(M42:M))), , COUNTA(M42:M))), " "), COUNTA(M42:M)-5+1, 5)),
"select "&TEXTJOIN(",", 1, IF(LEN(TRANSPOSE(SPLIT(REPT("♥♠", COUNTA(M42:M)-5+1), "♥"))),
"max(Col"&ROW(A1:A)&")", ))&"")),
"select Col2"))