2つの列があります。1つはセット内のすべてのアイテム、もう1つは現在持っているアイテムです。それらを比較し、一致した場合、一致した場合は少しのテキストが追加されるようにします。
その例では、列Aはセット番号、列Bは設定値、列Cは現在持っているもの、列Dは期待される結果です。
したがって、BとCを比較し、一致する名前がある場合は、Bに一致する名前に「CHECK」という単語を追加します。
「チェック」という言葉を追加するためにこれを行うことを考えました
=ARRAYFORMULA(B2:B & " -CHECK")
しかし、ここでLOOKUP
およびLEN
関数も必要ですか?
アプリのスクリプトはもっと簡単でしょうか?
D2セルに貼り付け、下にドラッグします。
=ARRAYFORMULA(TEXTJOIN(", ", 1, REGEXREPLACE(TRIM(IFERROR(SPLIT(B2, ","))),
TEXTJOIN("|", 1, IF(REGEXMATCH(TRIM(IFERROR(SPLIT(B2, ","))),
TEXTJOIN("|", 1, TRIM(IFERROR(SPLIT(C2, ","))))),
TRIM(IFERROR(SPLIT(B2, ","))), )), TRIM(IFERROR(SPLIT(B2, ",")))&" - CHECK")))
=ARRAYFORMULA(SUBSTITUTE(SUBSTITUTE(TRIM(TRANSPOSE(QUERY(TRANSPOSE(SUBSTITUTE(IF(ISNUMBER(
QUERY(QUERY(IFERROR(SPLIT(IF(IF(REGEXMATCH(TRIM(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(
TRANSPOSE(IFERROR(IF(SPLIT(B2:B, ",")<>"", "♠"&A2:A&"♦"&TRIM(IFERROR(SPLIT(B2:B, ","))), )))
,,999^99)),,999^99), "♠"))),SUBSTITUTE(TRIM(QUERY(TRANSPOSE(QUERY(TRANSPOSE(IFERROR(IF(
SPLIT(C2:C, ",")<>"", A2:A&"♦"&TRIM(IFERROR(SPLIT(C2:C, ","))), ))),,999^99)),,999^99))
, " ", "|")), TRIM(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(IFERROR(IF(
SPLIT(B2:B, ",")<>"", "♠"&A2:A&"♦"&TRIM(IFERROR(SPLIT(B2:B, ","))), ))),,999^99)),,999^99),
"♠")))&" - CHECK", )<>"", IF(REGEXMATCH(TRIM(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
IFERROR(IF(SPLIT(B2:B, ",")<>"", "♠"&A2:A&"♦"&TRIM(IFERROR(SPLIT(B2:B, ","))), )))
,,999^99)),,999^99), "♠"))),SUBSTITUTE(TRIM(QUERY(TRANSPOSE(QUERY(TRANSPOSE(IFERROR(IF(
SPLIT(C2:C, ",")<>"", A2:A&"♦"&TRIM(IFERROR(SPLIT(C2:C, ","))), ))),,999^99)),,999^99)),
" ", "|")), TRIM(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(IFERROR(IF(
SPLIT(B2:B, ",")<>"", "♠"&A2:A&"♦"&TRIM(IFERROR(SPLIT(B2:B, ","))), ))),,999^99)),,999^99),
"♠")))&" - CHECK", ), TRIM(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(IFERROR(IF(
SPLIT(B2:B, ",")<>"", "♠"&A2:A&"♦"&TRIM(IFERROR(SPLIT(B2:B, ","))), ))),,999^99)),,999^99),
"♠")))), "♦")), "select count(Col1) where Col1 is not null group by Col1 pivot Col2", 0),
"offset 1", 0)), INDEX(QUERY(IFERROR(SPLIT(IF(IF(REGEXMATCH(TRIM(TRANSPOSE(SPLIT(QUERY(
TRANSPOSE(QUERY(TRANSPOSE(IFERROR(IF(SPLIT(B2:B, ",")<>"", "♠"&A2:A&"♦"&TRIM(IFERROR(
SPLIT(B2:B, ","))), ))),,999^99)),,999^99), "♠"))),SUBSTITUTE(TRIM(QUERY(TRANSPOSE(QUERY(
TRANSPOSE(IFERROR(IF(SPLIT(C2:C, ",")<>"", A2:A&"♦"&TRIM(IFERROR(SPLIT(C2:C, ","))), )))
,,999^99)),,999^99)), " ", "|")), TRIM(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
IFERROR(IF(SPLIT(B2:B, ",")<>"", "♠"&A2:A&"♦"&TRIM(IFERROR(SPLIT(B2:B, ","))), )))
,,999^99)),,999^99), "♠")))&" - CHECK", )<>"", IF(REGEXMATCH(TRIM(TRANSPOSE(SPLIT(QUERY(
TRANSPOSE(QUERY(TRANSPOSE(IFERROR(IF(SPLIT(B2:B, ",")<>"", "♠"&A2:A&"♦"&TRIM(IFERROR(
SPLIT(B2:B, ","))), ))),,999^99)),,999^99), "♠"))),SUBSTITUTE(TRIM(QUERY(TRANSPOSE(QUERY(
TRANSPOSE(IFERROR(IF(SPLIT(C2:C, ",")<>"", A2:A&"♦"&TRIM(IFERROR(SPLIT(C2:C, ","))), )))
,,999^99)),,999^99)), " ", "|")), TRIM(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
IFERROR(IF(SPLIT(B2:B, ",")<>"", "♠"&A2:A&"♦"&TRIM(IFERROR(SPLIT(B2:B, ","))), )))
,,999^99)),,999^99), "♠")))&" - CHECK", ), TRIM(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(
TRANSPOSE(IFERROR(IF(SPLIT(B2:B, ",")<>"", "♠"&A2:A&"♦"&TRIM(IFERROR(SPLIT(B2:B, ","))), )))
,,999^99)),,999^99), "♠")))), "♦")), "select count(Col1) where Col1 is not null group by Col1
pivot Col2", 0), 1, ), ), " ", "♀")),,999^99))), " ", ", "), "♀", " "))