在 2 个表格中搜索相同的文本,然后选中它旁边的单元格

Search the same text in 2 tables then check the cell next to it

说明:我有 2 个 table,假设其中一个是随机生成的,可能包含第二个 table 中 5% 的内容,甚至更多。所以,第一个 table 假设有 3 个名字:Alex、Billy 和 John,每个名字旁边都有一个水果:Alex - 2 个苹果,Billy - 3 个梨,John - 5 个橙子。现在第二个 table 有了更多的名字,还有 Alex、Billy 和 John。我想得到数字并将它们添加到下一个 table 和水果的类型,我还想说如果亚历克斯有黄瓜他将从水果总量中得到 -1 和 - 的数量他已经拥有的水果(意味着只有一群人可以拥有黄瓜)。

在 Google sheet 中,我希望只有来自 "Name lists" 的第三组(最后一个)人能够拥有 "CT",其余的会因此受到惩罚(总量中的-1和总数中的数字)https://docs.google.com/spreadsheets/d/1n8DF771658l-7lIMu2Jx7YF9ZoHGb3H8UA0eOVd8iaE/edit?usp=sharing

项目自动化检查器中的所有内容

=ARRAYFORMULA(IFERROR(QUERY({E2:G}, 
 "select Col1,sum(Col2),Col3 where Col1 !='' 
  group by Col1,Col3 label sum(Col2)''", 0)-
 N(REGEXMATCH(QUERY(QUERY({E2:G}, 
 "select Col1,sum(Col2),Col3 where Col1 !='' 
  group by Col1,Col3 label sum(Col2)''", 0), 
 "select Col1", 0), "[^"&TEXTJOIN("$|^", 1, C2:C)&"$]")), QUERY({E2:G}, 
 "select Col1,sum(Col2),Col3 where Col1 !='' 
  group by Col1,Col3 label sum(Col2)''", 0)))

spreadsheet demo