版本低了,另外你这是EXCEL,需要将WPS专属的REGEXP函数替换为下面的方法,同时避免序号超过1位数字时出错:
- =LET(sha,Sheet1!A2:B10,shb,Sheet2!A2:B11,sRc,VSTACK(FILTER(sha,TAKE(sha,,1)<>""),FILTER(shb,TAKE(shb,,1)<>"")),s,BYROW(sRc,CONCAT),a,REDUCE(A1:F1,UNIQUE(s),LAMBDA(x,y,VSTACK(x,LET(fx,LAMBDA(xx,IFERROR(FILTER(OFFSET(xx,,2,,2),y=BYROW(xx,CONCAT)),{"",""})),ta,fx(sha),tb,fx(shb),tc,IF(CONCAT(ta)<>CONCAT(tb),HSTACK(LEFT(y,2*LEN(y)-LENB(y)),RIGHT(y,LENB(y)-LEN(y)),ta,tb),""),tc)))),FILTER(a,TAKE(a,,1)<>""))
复制代码
相应地,为避免序号超过1位数字时出错,WPS版的公式也稍作修改为:
- =LET(sha,Sheet1!A2:B10,shb,Sheet2!A2:B11,sRc,VSTACK(FILTER(sha,TAKE(sha,,1)<>""),FILTER(shb,TAKE(shb,,1)<>"")),s,BYROW(sRc,CONCAT),a,REDUCE(A1:F1,UNIQUE(s),LAMBDA(x,y,VSTACK(x,LET(fx,LAMBDA(xx,IFERROR(FILTER(OFFSET(xx,,2,,2),y=BYROW(xx,CONCAT)),{"",""})),ta,fx(sha),tb,fx(shb),tc,IF(CONCAT(ta)<>CONCAT(tb),HSTACK(REGEXP(y,{"(\d+)","[一-龟]+"}),ta,tb),""),tc)))),FILTER(a,TAKE(a,,1)<>""))
复制代码 |