按顺序将患者列表填写到医生列表

Fill a list of Patients to a list of Doctors by order

我有一个按日期排序的患者列表(或手动插入到列的末尾): https://docs.google.com/spreadsheets/d/1tJL6RVP55KYvno6cdD-qOmmR3tW4FAsb2WnW-684FR0/edit?usp=sharing

我有一份医生名单,其中有 4 名医生(或更多,仅举个例子)。现在我需要用规则填充这个列表中的那些患者:每个患者将被分配给 1 位医生。

例如:

或者

请帮忙。这是我需要的演示:https://docs.google.com/spreadsheets/d/1GH-XvsgLvVv5y4Q2irEgA6Vvblquz8KbwVlq_dErwDQ/edit#gid=0

粘贴在 doctor1 下并向右拖动:

=FILTER($A:$A, $A:$A<>"", MOD(ROW($A:$A)-COLUMN(B1), COUNTA($D:1))=0)


更高级的东西:

=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)))

demo spreadsheet