简体   繁体   English

如果vlookup与Google表格中的其他两个单元格匹配,如何减去两个单元格的值

[英]How to subtract the value of two cells if vlookup matches on two other cells in Google Sheets

Formula to compare B3 in sheet 1 to column A in sheet 2 (Defined Range Name - COUNTY). 将表1中的B3与表2中的A列进行比较的公式(定义的范围名称-COUNTY)。 If they match then subtract the value of A3 from D2 OR compare C3 in sheet 1 to column A in sheet 2 (Defined Range Name - COUNTY). 如果它们匹配,则从D2中减去A3的值,或将工作表1中的C3与工作表2中的A列进行比较(定义的范围名称-COUNTY)。 If they match then add the value of A3 to D2. 如果它们匹配,则将A3的值添加到D2。 This is what I have now and it is not adding or subtracting. 这就是我现在所拥有的,不是加法或减法。 It just carries down the previous total. 它只是保留以前的总数。

=IFERROR(SUMIFS(OR(VLOOKUP($B3,COUNTY),D2-$A3,OR(VLOOKUP($C3,COUNTY),D2+$A3))),D2)

例

you were close, but all your formulas after IFERROR are all wrong/incomplete. 您已经很接近了,但是IFERROR之后的所有公式都是错误的/不完整的。 paste this into D3 cell and drag down: 将此粘贴到D3单元格中并向下拖动:

=IF(REGEXMATCH(B3, TEXTJOIN("|", 1, County)), D2-A3, 
 IF(REGEXMATCH(C3, TEXTJOIN("|", 1, County)), D2+A3, D2))

0

You can do this by using MATCH combined with an ISERROR function. 您可以通过将MATCHISERROR函数结合使用来实现。 In cell D3 , write the following formula: 在单元格D3 ,编写以下公式:

=D2 - IF(ISERROR(MATCH(B3,COUNTY,0)),0,A3) + IF(ISERROR(MATCH(C3,COUNTY,0)),0,A3)

You can copy this down in column D. 您可以将其复制到D列中。

The way this works is that it starts with D2 , then subtracts, using an IF / ISERROR : 它的工作方式是从D2开始,然后使用IF / ISERROR减去:

  • By 0 (defined in formula), if U2 (cell B3) isn't in the range COUNTY because ISERROR would return TRUE 如果U2 (单元格B3) 不在 COUNTY范围内, ISERROR 0 (在公式中定义),因为ISERROR将返回TRUE
  • By 4 (cell A3), if U2 (cell B3) is in the range COUNTY , because ISERROR would return FALSE 通过4 (小区A3),如果U2 (小区B3)的范围COUNTY ,因为ISERROR将返回FALSE

The second part of the formula works the same way, but with an addition instead. 公式的第二部分以相同的方式工作,但有一个加法。

You can check references for the functions used here: 您可以在此处查看有关使用的功能的参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google Sheets REGEXEXTRACT 分成两个单元格 - Google Sheets REGEXEXTRACT splits into two cells 从 Google 表格中的单元格中删除 " 和 =+ - Remove " and =+ from cells in Google Sheets 删除 Google 表格单元格中的 HTML - Remove HTML In Google Sheets Cells 在 Google 表格中使用 REEXTRACT 提取与单元格之间的域名匹配的 email 地址 - Extracting an email address that matches the domain name between cells with REGEXTRACT in Google Sheets 如何检查Google表格中一系列单元格中是否存在标准? - How to check if a criterion is present in a range of cells in Google Sheets? 在Google表格中提取特定单元格的公式 - Formula to extract specific cells in google sheets 如果单元格有值,则添加三个单元格,如果没有,则添加两个 - Adding three cells if a cell has a value, and if it doesn't, adding two 如何提取某些字符并将其拆分为两个不同的单元格 - How to extract certain characters and split it into two different cells 将Google Analytics(分析)UTM跟踪添加到Google表格中的单元格 - Adding Google Analytics UTM tracking to cells in Google Sheets 如何根据 Google 表格中的条件格式列表为单元格着色 - How can I color cells based on list with conditional formatting in Google Sheets
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM