web-dev-qa-db-fra.com

Comparaison de deux cellules et ajout de texte aux valeurs correspondantes

J'ai deux colonnes, une avec tous les éléments d'un ensemble et une autre avec les éléments que j'ai actuellement. Je voudrais les comparer et pour que les résultats correspondants aient un peu de texte ajouté s'ils correspondent.

Donc, dans cet exemple, la colonne A est le nombre défini, la colonne B est les valeurs définies, la colonne C est ce que j'ai actuellement et la colonne D est le résultat attendu.

Je veux donc comparer B à C et s'il y a des noms correspondants, je veux que B ait le mot "CHECK" ajouté au nom correspondant.

J'ai pensé à faire cela pour ajouter le mot "CHECK"

=ARRAYFORMULA(B2:B & " -CHECK")

Mais ai-je également besoin d'une fonction LOOKUP et LEN ici?

Le script des applications serait-il plus facile?

1
littlecoder
  • coller la cellule D2 et faire glisser vers le bas:

    =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")))

    0


=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))), " ", ", "), "♀", " "))

0

1
user0