水平有限写的比较丑陋,先凑合看把
=IFERROR(VLOOKUP($A2,GROUPBY(TAKE(TAKE(VSTACK(Sheet2!$B$1:$J$1,HSTACK(SCAN(0,Sheet2!$A$3:$A$20,LAMBDA(x,y,IF(y="",x,y))),Sheet2!$C$3:$J$20)),,MATCH(B$1,Sheet2!$B$1:$J$1,0)),,1),TAKE(TAKE(VSTACK(Sheet2!$B$1:$J$1,HSTACK(SCAN(0,Sheet2!$A$3:$A$20,LAMBDA(x,y,IF(y="",x,y))),Sheet2!$C$3:$J$20)),,MATCH(B$1,Sheet2!$B$1:$J$1,0)),,-1),SUM,,0),2,0),0)+IFERROR(VLOOKUP($A2,GROUPBY(TAKE(TAKE(VSTACK(Sheet1!$B$1:$J$1,HSTACK(SCAN(0,Sheet1!$A$3:$A$20,LAMBDA(x,y,IF(y="",x,y))),Sheet1!$C$3:$J$20)),,MATCH(B$1,Sheet1!$B$1:$J$1,0)),,1),TAKE(TAKE(VSTACK(Sheet1!$B$1:$J$1,HSTACK(SCAN(0,Sheet1!$A$3:$A$20,LAMBDA(x,y,IF(y="",x,y))),Sheet1!$C$3:$J$20)),,MATCH(B$1,Sheet1!$B$1:$J$1,0)),,-1),SUM,,0),2,0),0)
|