I have a list of patients ordered by date (or manually insert to the end of the column):
Please help. Here is the demo of what I need:
CodePudding user response:
something more advanced:
=INDEX(IFERROR(VLOOKUP(SUBSTITUTE(D2:D, " ", CHAR(13)),
SPLIT(FLATTEN(TRIM(QUERY(REGEXREPLACE(SUBSTITUTE(QUERY({
FILTER(TEXT(ROW(A2:A), "000000")&"×"&A2:A, A2:A<>""), ARRAY_CONSTRAIN(FLATTEN(TRANSPOSE(
FILTER(TEXT(ROW(D2:D), "000000")&"×"&D2:D, D2:D<>"")&T(SEQUENCE(1,
ROUNDUP(COUNTA(A2:A)/COUNTA(D2:D)))))), COUNTA(A2:A), 2)},
"select max(Col1) group by Col1 pivot Col2"), " ", CHAR(13)),
"^(\d ×)", ),,9^9))), " "), SEQUENCE(1, ROUNDUP(COUNTA(A2:A)/COUNTA(D2:D)), 2), 0)))