提示:其它语言是由 Google 机器翻译的。 你可以访问 English 版本。
登录
x
or
x
x
马上登记
x

or

如何在Excel中使用AND,OR和NOT来使用IF函数?

在Excel中,IF函数对于检查单元格是否满足条件并根据评估结果(True和False)返回不同的值非常有用。 结合IF功能和AND,OR,NOT功能,它将改变检查单元的条件。 这里我将介绍如何使用IF和AND功能,IF和OR功能,以及在Excel中组合多个IF功能。

如何在Excel中使用IF函数

如何在Excel中使用If函数和AND函数

如何在Excel中使用IF函数和OR函数

如何在Excel中将一个公式中的多个IF函数组合在一起

轻松地将多个工作表/工作簿/ CSV文件组合成一个工作表/工作簿

将来自不同工作簿的几十张纸合并到一张纸上可能会很麻烦。 但用Excel的Kutools 合并(工作表和工作簿) 实用程序,只需点击几下即可完成! 全功能免费试用60天!

广告结合床单书1


假设我们有一个销售表,如下面的屏幕截图所示,现在我们要评估销售价值并将它们分组为“Unordinary“”“”中间“和”".

doc如果和或不是1

现在,将行标题和列标题复制到一个空白区域(示例中的范围A16:E28),如下面的屏幕截图所示。

doc如果和或不是2

Office选项卡在Office中启用选项卡式编辑和浏览,使您的工作更轻松......
Kutools for Excel - 最佳办公生产力工具将解决您的大部分Excel问题
  • 重用任何东西: 将最常用或最复杂的公式,图表和其他任何内容添加到您的收藏夹中,并在将来快速重复使用它们。
  • 超过20文本功能: 从文本字符串中提取数字; 提取或删除部分文本; 将数字和货币转换为英语单词...
  • 合并工具:多个工作簿和表格合二为一; 合并多个单元格/行/列而不丢失数据; 合并重复行和总和...
  • 拆分工具:根据价值将数据拆分为多个表格; 一个工作簿到多个Excel,PDF或CSV文件; 一列到多列......
  • 粘贴跳过 隐藏/过滤行; 数和总和 按背景颜色; 创建邮件列表和 通过Cell的价值发送电子邮件...
  • 超级过滤器: 创建高级过滤方案并应用于任何工作表; 排序 按周,日,频率等; 筛选 通过大胆,公式,评论......
  • 超过300强大的功能; 适用于Office 2007-2019和365; 支持所有语言; 在公司轻松部署; 全功能60天免费试用。

箭头蓝色右泡如何在Excel中使用IF函数

Excel中IF函数的基本形式如下所示: = IF(logic_test,value_if true,value_if_false)

在我们的情况下,我们要检查销售量是否低。 如果单元格B2中的值等于或小于80,则返回“低”的文本,如果单元格B2中的值大于80,则返回空白。

输入公式 = IF(B2 <= 80, “低”, “”) 到单元格B17,然后将填充句柄拖到范围B17:E28。 请参阅下面的截图:

doc如果和或不是3


箭头蓝色右泡如何在Excel中使用If函数和AND函数

如果要检查一个单元格是否同时满足多个条件,则可以在Excel中结合IF函数和AND函数。
Excel中AND函数的基本形式是 = AND(逻辑1,逻辑2,逻辑3,...等)

现在在我们的情况下,我们想要检查一个销售量超过80,同时小于160,如果是,则返回“中间”文本,如果没有返回空白。

输入公式 = IF(AND(B2> 80,B2 <160), “中”, “”) 到单元格B17中,然后将填充句柄拖到范围B17:E28。 请参阅下面的截图:

doc如果和或不是4


箭头蓝色右泡如何在Excel中使用IF函数和OR函数

如果要检查单元格是否满足多个条件之一,则可以在Excel中组合IF函数和OR函数。

Excel中OR函数的基本形式是 = OR(逻辑1,逻辑2,逻辑3,...等)

在我们的例子中,我们想找出大于180或小于20的非一般销售量。 如果出售量不合常规,请返回“不一般”的文本,如果不返回空白。

输入公式 = IF(OR(B2> 180,B2 <20), “Unordinary”, “”) 到单元格B17中,然后将填充句柄拖到范围B17:E28。 请参阅下面的截图:

doc如果和或不是5


箭头蓝色右泡如何在Excel中将多个IF函数组合到一个公式中

在我们的例子中,如果您想用一个公式评估所有销售量,则可以应用复杂的IF函数。

如果销售量等于或小于20,则返回“不寻常”的文字; 如果销售量等于或小于80,则返回“低”字样; 如果等于或小于160,则返回“Middle”的文本,如果等于或小于200,则返回“High”的文本。

输入公式 = IF(B2 <= 20,“Unordinary”,IF(B2 <= 80,“Low”,IF(B2 <= 160,“Middle”,IF(B2 <= 200,“High”,“”))) ) 到单元格B17中,然后将填充句柄拖到范围B17:E28。 请参阅下面的截图:

doc如果和或不是6

注意丝带 公式太难记了? 将公式保存为自动文本条目,以便将来只需点击一下即可重复使用!
阅读全文... 免费试用

Kutools for Excel - 最佳办公生产力工具提高80%的生产力

  • 重用: 快速插入 复杂的公式,图表 以及你以前用过的任何东西; 加密单元格 密码; 创建邮件列表 并发送电子邮件...
  • 超级方程式酒吧 (轻松编辑多行文字和公式); 阅读布局 (轻松读取和编辑大量单元格); 粘贴到过滤范围...
  • 合并单元格/行/列 不丢失数据; 分裂细胞含量; 组合重复的行/列...防止重复的细胞; 比较范围...
  • 选择复制或唯一 行; 选择空行 (所有细胞都是空的); 超级查找和模糊查找 在许多工作簿中; 随机选择......
  • 精确复制 多个单元格而不更改公式参考; 自动创建参考 多张表; 插入项目符号,复选框等等......
  • 提取文本,添加文本,按位置删除, 删除空间; 创建和打印分页小计; 在单元格内容和注释之间转换...
  • 超级过滤器 (将过滤方案保存并应用到其他工作表); 高级排序 按月/周/日,频率等; 特殊过滤器 用粗体,斜体......
  • 结合工作簿和工作表; 根据键列合并表; 将数据拆分为多个表格; 批量转换xls,xlsx和PDF...
  • 超过300强大的功能。 支持Office / Excel 2007-2019和365。 支持所有语言。 在您的企业或组织中轻松部署。 全功能60天免费试用。
kte tab 201905

Office选项卡为Office提供选项卡式界面,使您的工作更轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,Publisher,Access,Visio和Project。
  • 在同一窗口的新选项卡中打开并创建多个文档,而不是在新窗口中。
  • 通过50%提高您的工作效率,每天为您减少数百次鼠标点击!
官方底部
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Alice · 6 months ago
    8. To be a Bunk Leader, a staff member must have over 4 service years and have completed leadership training.
    In cell L2, enter a formula using the IF and AND functions, as well as structured references to determine if Adam Moriarty can be a bunk leader.
    a. The logical test in the IF function should determine if the staff member’s Service Years is greater than 4 AND the staff member’s Leadership Training status is “Yes”. Remember to use a structured reference to the Service Years and the Leadership Training columns.
    b. The function should return the text Yes if a staff member meets both of those criteria.
    c. The function should return the text No if a staff member meets none or only one of those criteria.
    • To post as a guest, your comment is unpublished.
      kellytte · 5 months ago
      Hi Alice,
      Supposing the number of service year is placed in Cell B2, the leadership training stats is placed in Cell C2, you can use this formula =IF(AND(B2>4,C2="Yes"),"Yes","No")
  • To post as a guest, your comment is unpublished.
    Nicolae · 7 months ago
    hello!
    I need your brilliant minds to resolve a problem:
    if a1=blank & b1=blank & c1=blank & d1=blank then result1
    if a1=blank & b1=blank & c1=blank & d1>0 then result2
    if a1=blank & b1=blank & c1>0 & d1>0 then result3
    if a1=blank & b1>0 & c1>0 & d1>0 then result4
    if a1>0 & b1>0 & c1>0 & d1>0 then result5
    Can you please help me with a formula?
    i've tried with if/and, if/or but it seams i can't get a result.

    Thanks in advance!
    • To post as a guest, your comment is unpublished.
      upsss · 6 months ago
      =IF(AND(ISBLANK(A1);ISBLANK(B1);ISBLANK(C1);ISBLANK(D1));1;IF(AND(ISBLANK(A1);ISBLANK(B1);ISBLANK(C1);D1>0);2;IF(AND(ISBLANK(A1);ISBLANK(B1);C1>0;D1>0);3;IF(AND(ISBLANK(A1);B1>0;C1>0;D1>0);4;5))))
  • To post as a guest, your comment is unpublished.
    Ahmed Mosih · 8 months ago
    Need some help with logic. I wanted to check the first cell for data if it has data then it will return that cell; if it doesn't have data then it will return a different cell. But if the second cell is blank then it should return a msg. Can you please help.
  • To post as a guest, your comment is unpublished.
    Kent Durbin · 10 months ago
    IF(D15>30,"Organic Soils",IF(AND(D15>25,D15<29.99),"Clayey Soil (fine)",IF(AND(D15>20,D15<24.99),"Loamy Soil (moderately fine)",IF(AND(D15>10,D15<19.99),"Loamy Soil (medium)",IF(AND(D15>5,D15<9.99),"Loamy Soil (moderately coarse)",IF(D15<4.99,"Sandy Soil (coarse)")))))) Can you find the error?
  • To post as a guest, your comment is unpublished.
    yourname · 10 months ago
    A,b,c,d,e,f,g,a,y
  • To post as a guest, your comment is unpublished.
    dinesh · 1 years ago
    Name Amount Profit Range
    A 10,000
    B 50,000
    C 42,500
    D 75,000
    E 85,000
    F 23,500
    G 16,000
    I 57,000
    J 81,000


    Profit Range Name
    Less than 10,000 A
    10,000-20,000 B
    20,000-30,000 C
    30,0000-50,000 D
    50,0000-75,000 E
    75,000-1,00,000 F

    Write profit range in 1st table.
    any Please say how to write formula for this
  • To post as a guest, your comment is unpublished.
    mgkramarao1 · 1 years ago
    i required how to steel calculation as per dia (8,10,12,16,20,25,32) and cutting length no of bars and numbers etc

    wise in excel format
  • To post as a guest, your comment is unpublished.
    arunima · 1 years ago
    how to use if condition for condition like if value of x lying in 60-80
  • To post as a guest, your comment is unpublished.
    Matt Odom · 1 years ago
    Hello all,


    I am trying to build an IF statement to help with our Service Level calculations. We need one Queue Name to have a different time requirement than all of the other queues. I am trying to figure out how to get the formula to count all Queue Names (Column B) to show they are within our Service Level Agreement (SLA) if they are in the queue for less than 30 seconds. However, for the Queue named TS_DX_CP_ES*, I need it to show it is within SLA if less than 90 seconds.

    I currently have the following formula in place and it works for the 90 second rule but if I try to next the IF formula and change the Queue Name and Time Requirement, I get an error.


    Formula that works currently =IF(AND([@[Queue Name]]="TS_DX_CP_ES*",[@[Queue time]]<0.00104166666666667),1,0)

    Formula that gives a #VALUE! Error - =IF(AND([@[Queue Name]]="TS_DX_CP_ES*",[@[Queue time]]<0.00104166666666667),1,0),IF(AND([@[Queue Name]]="TS_PLU_US*",[@[Queue time]]<0.000358796296296296),1,0)
  • To post as a guest, your comment is unpublished.
    Matt Odom · 1 years ago
    Hello all,


    I am trying to build an IF statement to help with our Service Level calculations. We need one Queue Name to have a different time requirement than all of the other queues. I am trying to figure out how to get the formula to count all Queue Names (Column B) to show they are within our Service Level Agreement (SLA) if they are in the queue for less than 30 seconds. However, for the Queue named TS_DX_CP_ES*, I need it to show it is within SLA if less than 90 seconds.

    I currently have the following formula in place and it works for the 90 second rule but if I try to next the IF formula and change the Queue Name and Time Requirement, I get an error.


    Formula that works currently =IF(AND([@[Queue Name]]="TS_DX_CP_ES*",[@[Queue time]]<0.00104166666666667),1,0)

    Formula that gives a #VALUE! Error - =IF(AND([@[Queue Name]]="TS_DX_CP_ES*",[@[Queue time]]<0.00104166666666667),1,0),IF(AND([@[Queue Name]]="TS_PLU_US*",[@[Queue time]]<0.000358796296296296),1,0)



    Any advice or help?
  • To post as a guest, your comment is unpublished.
    Pinaki Bhattacharyya · 1 years ago
    Hi,
    I have a problem. Please help me.

    In a row, 3 columns with different value must show a different interpretation in the target cell.


    =IF(A3>0,"Welcome",IF(B3>0,"Win",IF(C3>0,"Will","HI")))



    Thanks Pinaki
    • To post as a guest, your comment is unpublished.
      kelly001 · 1 years ago
      Hi Pinaki,
      In your formula, If A3 > 0, both B3 and C3 also might be greater than 0. Similarly, when B3 > 0, both A3 and C3 also might be greater than 0.

      Normally, in the If function, you can set =IF(A3>0, "Welcome",””), which means when A3>0, returns “welcome”, while when A3 is not less than 0, returns nothing. In this function, the two condition A3>0 and A3<=0 are exclusive.

      In my example =IF(B2<=20,"Unordinary",IF(B2<=80, "Low", IF(B2<=160, "Middle", IF(B2<=200, "High", "")))), The third condition B3<=160 includes the second condition B2<=80, and the second contains the first too.
  • To post as a guest, your comment is unpublished.
    Cab · 1 years ago
    Column A has Numerical Values. Column C & D have text.

    If 2 or more separate Numerical Values in any row of Column A match then evaluate those Rows in Column C & D for any Text that doesn't match a given Text and count as 1. If Text does match then a value of 0 is assigned.


    So if..

    A1:A2 = 1

    A3:A4 = 2

    C1=Dog
    C2=Cat
    C3=Dog
    C4: Horse


    D1=Cat
    D2=Dog
    D3=Horse
    D4=Dog


    Since A1 & A2 match each other, evaluate C1,C2,D1,D2 and if any cells do not match either "Dog" or "Cat" assign a value of 1. In this example, since all cells contain either "Dog" or "Cat" a value of 0 would be assigned.

    Furthermore,

    Since A3 & A4 match each other, evaluate C3,C4,D3,D4 and if any cells do not match either "Dog" or "Cat" assign a value of 1. In this example, since cells C4 & D3 contain something other than "Dog" or "Cat" a value of 1 would be assigned.


    Thank you in advance!
  • To post as a guest, your comment is unpublished.
    jessjess · 1 years ago
    Hello,
    What would the equation for the following be?

    In cell K2 enter a formula using the IF and OR functions, as well as structured references, to determine if Adam Moriarty can be a group leader.
    a. The IF function should first determine if the staff member’s Service Years is greater than 3 OR if the staff member’s college graduate status is “Yes”. Remember to use a structured reference to the Service Years and the College Graduate columns.
    b. The function should return the text Yes if a staff member meets one or both of those criteria.
    c. The function should return the text No if a staff member meets neither of those criteria.
  • To post as a guest, your comment is unpublished.
    MUHAMMAD HARIS · 1 years ago
    i wanna know one thing that i make a table of username and password in excel and there is a third part of them is status i wanna know that if i use a formula in a third column of status using multiple "if " and "or" for the column username where i can use both of them username or phone no then i entered password and it gives in a column of status login if username or phoneno one of them is used with password if someone enter symbols in username status failed. if someone can answer me this is for email validation in excel thanks if answered
    • To post as a guest, your comment is unpublished.
      Tang Kelly · 1 years ago
      Hi Haris,
      Could you send a screenshot about your problem?
  • To post as a guest, your comment is unpublished.
    Kiran · 1 years ago
    III
    II
    II
    II

    II
    II
    II
    II

    How can I make a formula in excel -If any one value of the column is III the result shall be displayed as III, if any value of the column is II then the result shall be displayed as II if II and III not present it shall be displayed as I
  • To post as a guest, your comment is unpublished.
    G · 1 years ago
    How would I write this into one function?


    If D26 and E26 are blank, then C26-L7
    If D26 is not blank and E26 is, then D26-L7
    If E26 is not blank, then E26-L7
    • To post as a guest, your comment is unpublished.
      Tang Kelly · 1 years ago
      =IF(AND(D26="",E26=""),(C26-L7),IF(AND(D26<>"",E26=""),D26-L7,E26-L7))
  • To post as a guest, your comment is unpublished.
    Michelle · 1 years ago
    I am trying to write a formula to look at

    1. Is the figure either over £1000, or under -£1000

    2. Plus is the next cell over 55% or more



    so far I have =OR(M4>=1000,M4<=-1000) which pulls in the over or under £1000 plus or minus but am unsure how to add the second criteria presume its an AND(N2>=55%) but when I add it to the formula it doesnt work.
    • To post as a guest, your comment is unpublished.
      Tang Kelly · 1 years ago
      Hi Michelle,
      Loading a screenshot can help us understand your problem and need much easier!
  • To post as a guest, your comment is unpublished.
    KJ · 1 years ago
    Hi. How can I write this as formula?

    If year is equal to current year, add 1.
    if year is previous year, add 1 OR start 1.
    if year is 2 years prior, add 1 OR start 1.
  • To post as a guest, your comment is unpublished.
    FG · 1 years ago
    Hi Everyone, I need to write a formula for the following:

    IF A1 = "BOTTOMS" AND A9 <14, then 14, otherwise A9

    OR A1 = "TOPS" AND A9 <5, then 5, otherwise A9
    • To post as a guest, your comment is unpublished.
      Tang Kelly · 1 years ago
      Hi FG,
      You can’t create a formula to meeting one of both your conditions in Excel.
      • To post as a guest, your comment is unpublished.
        FG · 1 years ago
        Hi Kelly!

        I actually figured out a workaround!


        =ROUND((IFERROR((IF(OR(AND($I9="BOTTOMS",BL9>=$BY$3),AND($I9="TOPS",BL9>=$BY$4)),BL9,VLOOKUP($I9,$BX$3:$BY$4,2,FALSE))),0)),0)


        I9 - populates "BOTTOMS" or "TOPS" dependant on merchandise code entered
        BL9 - minimum set defined by store indice
        BY9 - minimum set defined by buyer (i.e the 14 units for bottom and and the 5 units for tops)
        BX$3:$BY$4 - vlookup to minimum set defined by buyer if if statement is false
  • To post as a guest, your comment is unpublished.
    Kim Detera · 1 years ago
    Hello! I am currently creating a template that will provide me a value depending on the score of the trainee.


    I was hoping I can add a value of 5 for any team member who gets a certain quiz %


    Here's what I'm thinking.


    5= 100%
    4= 99.9% to 90%
    3= 90% to 85%
    2= 85% to 80%
    1= <79.99


    I hope you guys can help me with the formula
  • To post as a guest, your comment is unpublished.
    Dan · 1 years ago
    Hello, I have a pretty complex formula I am trying to write and it is killing me to admit defeat on this one. So far I have:


    =IF(AND(B2="Prudential",OR(C2={"10 Year Term","15 Year Term","20 Year Term","30 Year Term"})),D2*0.75,(IF(C2="UL",D2*0.8,"0")))


    and it works just fine. However, I need to add about 37 more companies with their own commission structures to it. I am pretty sure I just need one monster OR statement with a bunch of nested IFs thrown in I just am at my wits end on figuring out exactly where to place them. Any help would be amazing. Thank you!
    • To post as a guest, your comment is unpublished.
      Anh Nguyen · 1 years ago
      Hi Dan,
      Your question is still unclear. you might to explain more by providing a solution for at least 2 companies. However, just help to shorten your OR function a bit. OR(C2={"10","15","20","30"}&" Year Term").
  • To post as a guest, your comment is unpublished.
    LINCY · 1 years ago
    =IF(OR((I2=(T2+U2),(I2=(U2+V2)),"Closed","OPEN")
    HOW TO MAKE THIS RIGHT?
  • To post as a guest, your comment is unpublished.
    Mirko Tipka · 1 years ago
    Im trying to do IF(OR(A1=1;AND(A2=1;A3=1)))
    • To post as a guest, your comment is unpublished.
      Tang Kelly · 1 years ago
      Hi Mirko,
      Thank you for your comment. What calculation result do you want to get? Could you tell me more about your problem?
  • To post as a guest, your comment is unpublished.
    Dan Kinnefer · 2 years ago
    I'm trying to make the formula return 4 possible answer which is (R-regular,A-absent,L-late,OT-overtime). My basis for regular is if the value of the cell is "8". So this is the formula that I made so far =IF(H16>7.9,"OT",IF(H16<7.9,"L",IF(H16=8,"R","A"))). It only returns (OT and L) something is very wrong and i can't figure it out. I'm just new to excel so please help me
    • To post as a guest, your comment is unpublished.
      Tang Kelly · 2 years ago
      Hi Dan,
      Try this formula =IF(H16=8,"R",IF(H16<7.9,"OT","L"))
  • To post as a guest, your comment is unpublished.
    Dan Kinnefer · 2 years ago
    I'm trying to make the formula return 4 possible answer which is (R-regular,A-absent,L-late,OT-overtime). My basis for regular is if the value of the cell is "8". So this is the formula that I made so far =IF(H16>7.9,"OT",IF(H16<7.9,"L",IF(H16=8,"R","A"))). It only returns (OT and L) something is very wrong and i can't figure it out. I'm just new to excel so please help me.
    • To post as a guest, your comment is unpublished.
      Anh Nguyen · 1 years ago
      Try this: =IF(OR(H16=0,H16=""),"A",IF(H16=8,"R",IF(H16<7.9,"L","OT")))
  • To post as a guest, your comment is unpublished.
    pramod · 2 years ago
    how to determine the age of the cell ? is this formula right =IF(I2<30,"future payment",AND(IF(I2>30<=45,"30-45days",AND(IF(I2>45<=60,"45-60days",AND(IF(I2>60,"61+days
    ",0)))))))
    • To post as a guest, your comment is unpublished.
      Tang Kelly · 2 years ago
      Hi pramod,
      You cannot use I2>30<=45 in formula directly. I have changed the formula for you: =IF(I2<=30,"FUTURE PAYMENT",IF(B2<=45, "30-45 DAYS", IF(B2<=45, "45-60DAYS", IF(B2<=60, "60+DAYS", ""))))
  • To post as a guest, your comment is unpublished.
    Raman V · 2 years ago
    I have charges calculation for eg. charges amount is 0 then next column should be 0. if charges is more than 1 and less than 250 then next column should be 250. If charges is more than 250 then actual charges should come in next column(252)
  • To post as a guest, your comment is unpublished.
    marhsall · 2 years ago
    how do i make this formulas talk to one another:

    =IF(OR(AND(MID(K2,6,1)="N",(MID(K2,6,1)="C"),(MID(K2,6,1)="H"),(MID(K2,6,1)="I"),(MID(K2,6,1)="B"),(MID(K2,6,1)="F"),(MID(K2,6,1)="L"),(MID(K2,6,1)="M"),(MID(K2,6,1)="P"),(MID(K2,6,1)="R"),(MID(K2,6,1)="P"),ISTEXT(G2)="61"),OR(AND(RIGHT(K2,2)=G2))),"Good","Review")

    =IF(AND(RIGHT(K2,2)=G2),"Good","Review")


    or =IF(NOT(OR(AND(MID(K2,6,1)="N",(MID(K2,6,1)="C"),(MID(K2,6,1)="H"),(MID(K2,6,1)="I"),(MID(K2,6,1)="B"),(MID(K2,6,1)="F"),(MID(K2,6,1)="L"),(MID(K2,6,1)="M"),(MID(K2,6,1)="P"),(MID(K2,6,1)="R"),(MID(K2,6,1)="P"),ISTEXT(G2)="61"),(RIGHT(K2,2)=G2))),"Good","Review")