=CHOOSECOLS(DROP(PIVOTBY(LET(a,DROP(REDUCE("",DROP(SHEETSNAME(,1,1),-2),LAMBDA(x,y,VSTACK(x,IFNA(HSTACK(INDIRECT(y&"!A1"),INDIRECT(y&"!B4:G11")),INDIRECT(y&"!A1"))))),1),CHOOSECOLS(FILTER(a,(CHOOSECOLS(a,4)<>0)*(LEN(CHOOSECOLS(a,4))>4)),4,5,6)),BYROW(IF(ISNUMBER(FIND(C3:D3,LET(a,DROP(REDUCE("",DROP(SHEETSNAME(,1,1),-2),LAMBDA(x,y,VSTACK(x,IFNA(HSTACK(INDIRECT(y&"!A1"),INDIRECT(y&"!B4:G11")),INDIRECT(y&"!A1"))))),1),CHOOSECOLS(FILTER(a,(CHOOSECOLS(a,4)<>0)*(LEN(CHOOSECOLS(a,4))>4)),1)))),C3:D3,""),LAMBDA(a,TEXTJOIN("",1,a))),LET(a,DROP(REDUCE("",DROP(SHEETSNAME(,1,1),-2),LAMBDA(x,y,VSTACK(x,IFNA(HSTACK(INDIRECT(y&"!A1"),INDIRECT(y&"!B4:G11")),INDIRECT(y&"!A1"))))),1),CHOOSECOLS(FILTER(a,(CHOOSECOLS(a,4)<>0)*(LEN(CHOOSECOLS(a,4))>4)),3)),SUM),1),1,4,5,6,2,3)
可以优化一下
|