本帖最后由 tmplinshi 于 2024-3-17 18:46 编辑
Excel 365 可用- =LET(
- src, A2:B26,
- cat, H1:J11,
- a, SCAN(, INDEX(src, , 1), LAMBDA(x, y, IF(y = "", x, y))),
- b, INDEX(src, , 2),
- arr, IF(SEQUENCE(ROWS(a)) = MATCH(a & b, a & b, 0), b, ""),
- DROP(REDUCE("", arr, LAMBDA(out, x,
- IF(x = "", VSTACK(out, x), LET(
- x, TEXTBEFORE(x, "、",,,, x),
- i, MAX(IF(cat = x, SEQUENCE(, COLUMNS(cat)))),
- c, INDEX(cat, 1, i),
- py, SWITCH(c, "水果", "SG", "办公", "BG", "五金", "WJ"),
- n, COUNT(SEARCH(c & "*", out)) * 2^(py = "WJ") + 1,
- VSTACK(out, IF(i, c & py & n & IF(py = "WJ", "~" & py & n + 1, ""), ""))
- ))
- )), 1)
- )
复制代码
|