跳到主要内容

如何在Excel中将IF函数与AND,OR和NOT一起使用?

Excel 的 IF 函数证明了数据处理中逻辑运算的强大功能和多功能性。 IF 函数的本质是它评估条件并根据这些评估返回特定结果的能力。它的运作遵循一个基本逻辑:

=IF(condition, value_if_true, value_if_false)

当与 AND、OR 和 NOT 等逻辑运算符结合使用时,IF 函数的功能将显着扩展。这种组合的强大之处在于它们能够同时处理多种条件,提供能够适应各种复杂场景的结果。在本教程中,我们将探讨如何有效利用 Excel 中的这些强大功能来解锁数据分析的新维度并增强您的决策过程。让我们深入研究并发现这些强大的 Excel 函数的实际应用!

嵌套 IF AND OR NOT 公式


如果与公式

评估多种条件并提供特定结果 当满足所有条件时 (TRUE),并且当任何条件不满足 (FALSE) 时会产生不同的结果,您可以将 AND 函数合并到 IF 语句的逻辑测试中。其结构是:

=IF(AND(condition1, condition2, …), value_if_all_true, value_if_any_false)

例如,假设您是一名分析学生成绩的老师。您想要根据两个标准确定学生是否通过: 分数高于70分 AND 出席率超过80%.

  1. 首先检查第一个学生的数据,他们的分数位于单元格 B2 中,出勤率位于单元格 C2 中。对于该学生,在 D2 中应用以下公式:
    =IF(AND(B2>70, C2>80%), "Pass", "Fail")
    提示: 此公式检查 B2 的分数是否高于 70 分以及 C2 的出勤率是否高于 80%。如果两个条件都满足,则返回“Pass”;否则,返回“失败”。
  2. 将公式向下拖动到列中以评估每个学生的分数和出勤率。

    如果与公式


如果或公式

评估多个条件并返回特定结果 当满足任一条件时 (TRUE),并且当所有条件都不满足时(FALSE)会得到不同的结果,因此可以在 IF 语句的逻辑测试中使用 OR 函数。公式结构如下:

=IF(OR(condition1, condition2, …), value_if_any_true, value_if_all_false)

例如,在教育背景下,考虑更灵活的学生通过标准。在这里,如果学生满足以下条件,则视为通过 要么得分高于 90 OR 出勤率高于95%.

  1. 首先评估第一个学生的表现,他们的分数在单元格 B2 中,出勤率在单元格 C2 中。在相邻单元格(例如 D2)中应用公式来评估:
    =IF(OR(B2>90, C2>95%), "Pass", "Fail")
    提示: 此公式评估学生 B90 成绩是否高于 2 分或 C95 出勤率是否超过 2%。如果满足任一条件,则返回“Pass”;如果没有,则“失败”。
  2. 将此公式复制到列中,将其应用于列表中的每个学生,从而可以根据这些标准快速评估每个学生的通过资格。

    如果或公式


如果不是公式

评估条件并返回特定结果 如果不满足条件(FALSE),并且如果满足条件 (TRUE) 则得到不同的结果,IF 语句中的 NOT 函数就是您的解决方案。该公式的结构为:

=IF(NOT(condition), value_if_false, value_if_true)

举一个实际的例子,考虑一个工作场所场景,其中员工奖金是根据他们的出勤记录确定的。员工有资格获得奖金,如果 未缺勤超过 3 天.

  1. 要评估第一个员工的缺勤天数(其缺勤天数位于单元格 B2 中),请使用以下公式:
    =IF(NOT(B2>3), "Eligible", "Not Eligible")
    提示: 此公式检查 B2 中缺勤的天数。如果不超过3,则返回“Eligible”;否则,“不符合资格”。
  2. 将此公式复制到列中以将其应用于每个员工。

    如果不是公式


具有 IF 和逻辑函数的高级场景

在本节中,我们将探讨 Excel 的 IF 函数与 AND、OR 和 NOT 等逻辑运算符的复杂用法。本节涵盖从区分大小写的计算到嵌套 IF 语句的所有内容,展示了 Excel 在复杂数据分析中的多功能性。


如果满足你的条件,那么计算

除了提供预定义的结果外,Excel IF 函数与 AND、OR 和 NOT 等逻辑运算符结合使用时,还可以根据设置的条件是真还是假来执行各种计算。在这里,我们将使用 IF AND 组合作为示例来展示此功能。

假设您正在管理一个销售团队并想要计算奖金。您决定一名员工 获得销售额 10% 的奖金 如果他们 销售额超过 100 美元 AND 每周工作超过 30 小时.

  1. 对于初始评估,请查看 Alice 的数据,其中包括单元格 B2 中的销售额和单元格 C2 中的工作时间。在 D2 中应用此公式:
    =IF(AND(B2>100, C2>30), B2*0.1, 0)
    提示: 如果 Alice 的销售额超过 10 美元且工作时间超过 100 小时,此公式会计算 Alice 销售额的 30% 奖金。如果满足两个条件,则计算奖金;否则计算奖金。否则,返回 0。
  2. 通过将此公式复制到列中,将其扩展到团队的其他成员。这种方法确保每个员工的奖金都是根据相同的标准计算的。

    IF 那么计算

请注意: 在本节中,我们重点讨论使用 IF 函数和 AND 来根据特定条件进行计算。此概念还可以扩展到包括 OR 和 NOT 以及嵌套逻辑函数,从而允许在 Excel 中进行各种条件计算。


区分大小写的 AND、OR 和 NOT 语句

在 Excel 中,虽然 AND、OR 和 NOT 等逻辑函数通常不区分大小写,但在某些情况下,文本数据中的区分大小写至关重要。通过整合 精确函数 使用这些逻辑运算符,您可以有效地处理此类区分大小写的情况。在本节中,我们以区分大小写的方法为例演示 IF 和 OR 函数的使用。

想象一个零售场景,如果产品满足以下任一条件,则该产品有资格进行促销: 销售额超过 100 美元 OR 在区分大小写的检查中,其代码与“ABC”完全匹配.

  1. 对于第 2 行中列出的第一个产品,其销售额位于单元格 B2 中,产品代码位于单元格 C2 中,请在 D2 中使用以下公式:
    =IF(OR(B2>100, EXACT(C2,"ABC")), "Promotion Eligible", "Not Eligible")
    提示: 此公式评估 B2 中的销售额是否超过 100 美元或 C2 中的产品代码恰好是“ABC”。满足这些条件之一即可使该产品有资格进行促销;两者均不合格则不合格。
  2. 在所有产品的列中复制此公式,以根据销售额和区分大小写的产品代码标准统一评估其促销资格。

    区分大小写的 IF OR 公式

请注意: 在本节中,我们演示了如何使用 IF 和 OR 函数以及 EXACT 函数来进行区分大小写的计算。同样,您可以在 IF 公式中应用 EXACT 函数,并结合 AND、OR、NOT 或嵌套逻辑函数,以满足 Excel 中各种区分大小写的要求。


将 IF 与嵌套的 AND、OR、NOT 语句集成

Excel 的 IF 函数与 AND、OR 和 NOT 嵌套时,提供了一种简化的方法来处理更多层次的条件。本节提供了一个示例,展示这些嵌套函数在零售环境中的应用。

假设您正在监督一个负责各种产品类别的团队,并且您想要确定他们的奖金资格。如果员工符合以下条件,则有资格获得奖金: 销售额超过 100 美元, 和任一 每周工作超过 30 小时 OR 不属于电子部门。

  1. 首先,评估 Anne 的绩效,她的销售额在单元格 B2 中,工作时间在单元格 C2 中,部门在单元格 D2 中。 E2 中的公式为:
    =IF(AND(B2>100, OR(C2>30, NOT(D2="Electronics"))), "Eligible", "Not Eligible")
    提示: 此公式检查 Anne 的销售额是否超过 100 美元,并且工作时间是否超过 30 小时或不从事电子产品工作。如果她符合这些标准,她就被视为“合格”;如果不符合,则“不符合资格”。
  2. 将此公式复制到每位员工的列中,以根据其销售额、工作时间和部门来统一评估奖金资格。

    嵌套 IF AND OR NOT 公式


带有 AND、OR、NOT 的嵌套 IF 函数

当数据分析涉及多个条件检查时,Excel 中的嵌套 IF 函数提供了强大的解决方案。此方法需要为不同的条件构造单独的 IF 语句,包括 AND、OR 和 NOT 逻辑,然后将它们集成到一个简化的公式中。

考虑一个工作场所,其中 员工绩效被评为“优秀”、“良好”或“一般” 4.9分 销售额、工作时间和政策遵守情况:

  • “优秀”表示销售额超过 150 美元且工作时间超过 35 小时。
  • 否则,销售额超过 100 美元或违反政策不超过 1 次则为“良好”。
  • 如果这两个条件都不满足,则“公平”。

要根据上述条件评估每位员工的绩效,请执行以下操作:

  1. 从 Anne 的评估开始,其销售额位于单元格 B2 中,工作时间位于单元格 C2 中,政策违规情况位于单元格 D2 中。 E2中嵌套的IF公式为:
    =IF(AND(B2>150, C2>35), "Excellent", IF(OR(B2>100, NOT(D2>1)), "Good", "Fair"))
    提示: 此公式首先检查 Anne 的销售额和工时是否符合“优秀”标准。如果不是,则评估她是否符合“Good”资格。如果这两个条件都不满足,她就被归类为“一般”。
  2. 将这个嵌套 IF 公式扩展到每位员工,以根据多个标准一致地评估他们的绩效。

    嵌套 IF 函数


将 IF 与 AND OR NOT 结合使用:常见问题

本节旨在解决在 Microsoft Excel 中将 IF 与 AND、OR 和 NOT 结合使用的常见问题。

AND、OR 和 NOT 函数可以支持多少个条件?
  • AND 和 OR 函数最多可支持 255 个单独的条件。但是,建议仅使用一些公式,以避免公式过于复杂而难以维护。
  • NOT 函数只接受一个条件。
我可以在这些函数中使用 、= 等运算符吗?

当然,在Excel的AND、OR、NOT函数中,可以利用小于()、等于(=)、大于等于(>=)等运算符来建立条件。

为什么这些函数中会出现#VALUE 错误?

如果公式不满足任何指定的条件或者公式的结构存在问题,Excel 的 AND、OR 和 NOT 函数中经常会出现 #VALUE 错误。它表示 Excel 无法正确解释公式中的输入或条件。


以上是与在 Excel 中使用 IF 与 AND、OR 和 NOT 函数相关的所有相关内容。我希望本教程对您有所帮助。如果您想探索更多 Excel 提示和技巧, 请点击这里 访问我们广泛收集的超过数千个教程。

Comments (72)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hey Friends,

Donno if this Forum works now:

I am trying to figure out a formula for the following:
I have 3 Columns : viz : A1,D1, L1 with text contents. And output expected in M1

So if any of the cells A,D,L has Faulty mentioned, then M1 should result "Faulty", Else if all 3 are blank , need "Spare", and if any cell has any data then it shoud show "Mapped"
This comment was minimized by the moderator on the site
Kan iemand mij helpen met onderstaande voor het maken van een formule?
als B2 de tekst factuur staat moet in cel D8 de tekst factuurdatum komen te staan. Als in cel B2 de tekst offerte staat moet in cel D8 offertedatum komen te staan.

Alvast hartelijk dank
This comment was minimized by the moderator on the site
Hi there,

Can you show us the look of the text invoice, text quotation and text quotation date?
This comment was minimized by the moderator on the site
I am trying to write a formula to populate scores based off a range of values. This is what I have so far:

=IF(C2>=104.5%,"5", IF(C2<=104.49%,"4", IF(C2>=95.5%,"4", IF(C2<=95.49%,"3", IF(C2>=79.5%,"3", IF(C2<=79.49%,"2", IF(C2>=59.5%,"2", IF(C2<=59.49%,"1"""))))))))

The formula is working and I am not receiving any error messages. However, it is not populating the lower range values correctly. Here is my range:

>105% = 5
96%-105% = 4
80%-95% = 3
60%-79% = 2
<60% = 1

Any help is greatly appreciated.
This comment was minimized by the moderator on the site
Hi there,

I've fixed the formula as shown below:
=IF(C2>105%,"5",IF(C2>=96%,"4",IF(C2>=80%,"3",IF(C2>=60%,"2","1"))))

Hope this is what you want.

Amanda
This comment was minimized by the moderator on the site
Never mind, I figured it out. Thanks!
This comment was minimized by the moderator on the site
Kan iemand mij helpen aan onderstaande formule?
Alvast bedankt!

als Q groter is dan C dan Q en als Q kleiner is dan H dan H tenzij H 0 is dan is Q
This comment was minimized by the moderator on the site
Hi there,

Suppose, Q=A1, C=A2, H=A3. Please use the formula below: =IF(B1>B2,B1,IF(B1<B3,IF(B3=0,B1,B3),B3))

Hope this is what you want.

Amanda
This comment was minimized by the moderator on the site
I am trying to find a formula when realignment is in column A then add the text conflict when transition begins date (B) is >= the solution start date in column D OR if activation in column A then add the text conflict when transition begins date is <= solution start date in column D OR if deactivation then add the text conflict when transition begins date is >= the solution start date
A B C D E
Transition Type Transition Begins Transition Ends Solution Start Date Solution End Date
Realignment 11/1/2022 11/15/2022 1/15/2022 3/6/2022
Realignment 11/1/2022 11/15/2022 1/15/2022 3/16/2022
Realignment 11/1/2022 11/15/2022 6/1/2022 7/16/2022
Realignment 11/1/2022 11/15/2022 6/1/2022 7/16/2022
Realignment 11/1/2022 11/15/2022 6/1/2022 7/16/2022
Activation 1/1/2022 1/31/2022 1/15/2022 3/6/2022
Deactivation 12/1/2021 12/15/2021 1/15/2022 3/6/2022
Reorganization 2/6/2022 2/12/2022 1/15/2022 3/6/2022
Activation 12/1/2021 12/31/2021 11/1/2029 12/31/2029
Activation 12/1/2021 12/31/2021 2/1/2025 7/31/2025
Activation 12/1/2021 12/31/2021 4/1/2024 6/29/2024
Activation 12/1/2021 12/31/2021 2/1/2028 3/2/2028
Activation 12/1/2021 12/31/2021 2/1/2022 5/20/2025
Activation 12/1/2021 12/31/2021 9/6/2022 3/16/2023
Activation 12/1/2021 12/31/2021 6/1/2024 11/28/2024
Activation 12/1/2021 12/31/2021 9/1/2022 9/7/2022
Deactivation 10/1/2021 10/30/2021 11/1/2029 12/31/2029
Deactivation 10/1/2021 10/30/2021 2/1/2025 7/31/2025
Deactivation 10/1/2021 10/30/2021 4/1/2024 6/29/2024
Deactivation 10/1/2021 10/30/2021 2/1/2028 3/2/2028
Deactivation 10/1/2021 10/30/2021 2/1/2022 5/20/2025
Deactivation 10/1/2021 10/30/2021 9/6/2022 3/16/2023
Deactivation 10/1/2021 10/30/2021 6/1/2024 11/28/2024
Deactivation 10/1/2021 10/30/2021 9/1/2022 9/7/2022
Reorganization 2/1/2022 2/28/2022 11/1/2029 12/31/2029
Reorganization 2/1/2022 2/28/2022 2/1/2025 7/31/2025
This comment was minimized by the moderator on the site
Hi there,

What do you mean by adding the text conflict? Can you show me the result you want?

Amanda
This comment was minimized by the moderator on the site
=IF(AND(AY7>60,AY7>30),"0.02","0.04"),if(and(ay7<=30,ay<az),"0.06"),if(and(ay7<=15,ay<az),"0.08")
This comment was minimized by the moderator on the site
I am trying use If formula for one oridinary file, lets say I have number from 1 to 31 in a perticular cell. I need to show the result in another cell as if number in that perticular cell is less than 26 they it will zero, if the number in that perticular cell is from 26 to 30 then it will show the same number but if the number is abobe 30 then it will show the 30 only....Can anyone advise me how can I formulate this formula?
This comment was minimized by the moderator on the site
Hi there,

Please try the formula below: =IF(A1<26,0,IF(A1<=30,A1,30))

Hope this could help you.

Amanda
This comment was minimized by the moderator on the site
Ciao,
mi potete aiutare perfavore...
ho tre celle:
1-data di pagamento
2-totale
3-totale se pagato

vorrei che quando inserisco la data di pagamento(1), la casella 3(che è vuota) si riempisse automaticamente come la casella 2
come posso fare?
This comment was minimized by the moderator on the site
Hi there,

Do you want to fill the value of the cell 2 in the cell 3?
If so, you can enter this IF formula in the casella 3: =IF(casella 1<>"",casella 2,"")

Amanda
This comment was minimized by the moderator on the site
=IF(D4<=30000, and =>20000,than D4a-5000,and if(d4<=40000, and >30000, than d4-6000) convert into formula
This comment was minimized by the moderator on the site
Try the formula. Since I don't quite understand you, please check and change the part "DA4-5000" and "D4-6000", "FALSE" to the results you want.
=IF(AND(D4<=30000,D4>20000),"DA4-5000",IF(AND(D4<=40000,D4>30000),"D4-6000","FALSE"))
Amanda
This comment was minimized by the moderator on the site
HI EVERY ONE I NEED HELP IN THIS SYNTEX=IF(AND(AJ=1250,AJ*2.5%),IF(AND(AJ>1250,AJ<=2500),AJ*10%,IF(AND(AJ>2500,AJ<=3750),AJ*15%,IF(AND(AJ>3750,AJ<=11666),AJ*20%))))
THIS FOURMAIL GIVE ME #NAME WHERE THE EROO
This comment was minimized by the moderator on the site
Hi ahmed.dba,
Can you send the file to ? And if you have private information in the file, please delete them.
Amanda
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations