Comments on: Excel logical operators: equal to, not equal to, greater than, less than

Many tasks you perform in Excel involve comparing data in different cells. For this, Microsoft Excel provides six logical operators, which are also called comparison operators. This tutorial aims to help you understand the insight of Excel logical operators and write the most efficient formulas for your data analysis. Continue reading

Comments page 9. Total comments: 1256

  1. I have a data four cell in excel now i want to summation both of data but if i input one cell less then 9 or equal to any character the output will be zero. How can i solve this issue. plzz do the ans for the question.

  2. Hi Svetlana,

    First I want to mention that I respect if you do not have the time to help and since you actually are making an income working with Excel I understand if you do not are able to help out.

    I have searched on Internet "everywhere", but do not find the correct "programming" that works for me in my Excel sheet.

    To start with, I work with time and a sheet using 24 hour and beyond this. Time can start at 21:00 and finish at 28:00 or 14:30 ending at 25:20 (that is the data I have (working hours and the extra amount of money we get working late)).

    19-22 and 22-30
    The rules I try to set is to find time that passes 19:00 and ends before 30:00 (06:00). Also I want to know if how much time is between 19:00 - 22:00 and how much is between 22:00 and 30:00.

    Break (no extra payment)
    For an example working hours are 14:00-23:30. Then we get three hours of extra payment between 19:00-22:00 and a higher amount of money between 22:00-23:30. But we do not get paid that extra money, below I have added a break between 18.30-19:30.

    First I want to extract the 19:30 into one cell, 22:00 to the next, after that also 22:00 separately and at the end 23:30.

    This is how I want it to look...

    C2-14:00 Work starts (actual data)
    C3-23:30 Work ends (actual data)
    C4-18:30 Break starts (actual data, no payment from this time)
    C5-19:30 Break ends (actual data, no payment to this time)
    C6-19:30 Start time of lower payment (=IF... ) to get this result
    C7- 22:00 End time of lower payment (=IF... ) to get this result
    C8-22:00 Start time of higher payment (=IF... ) to get this result
    C9-23:30 End time of higher payment (=IF... ) to get this result

    Also to make sure the formulas work if the working hours are between 16:00-25:02 break at 21:20-22:40, 21:30-29:50 break at 25:00, 24:01-31:00 or 23:40-28:00 breaks embedded at any time...
    I have tried this, but could not make it work.

    Will this take to much time to write formulas that makes this work?

    Best regards

    Tom S

  3. Hi Svetlana,

    First I want to mention that I respect if you do not have the time to help and since you actually are making an income working with Excel I understand if you do not are able to help out.

    I have searched on Internet "everywhere, but do not find the correct "programming" that works for me in my Excel sheet.

    To start with, I work with time and a sheet using 24 hour and beyond this. Time can start at 21:00 and finish at 28:00 or 14:30 ending at 25:20 (that is the data I have (working hours and the extra amount of money we get working late)).

    19-22 and 22-30
    The rules I try to set is to find time that passes 19:00 and ends before 30:00 (06:00). Also I want to know if how much time is between 19:00 - 22:00 and how much is between 22:00 and 30:00.

    Break (no extra payment)
    For an example working hours are 14:00-23:30. Then we get three hours of extra payment between 19:00-22:00 and a higher amount of money between 22:00-23:30. But we do not get paid that extra money, below I have added a break between 18.30-19:30.

    First I want to extract the 19:30 into one cell, 22:00 to the next, after that also 22:00 separately and at the end 23:30.

    This is how I want it to look...

    C2-14:00 Work starts (actual data)
    C3-23:30 Work ends (actual data)
    C4-18:30 Break starts (actual data, no payment from this time)
    C5-19:30 Break ends (actual data, no payment to this time)
    C6-19:30 Start time of lower payment (=IF... ) to get this result
    C7- 22:00 End time of lower payment (=IF... ) to get this result
    C8-22:00 Start time of higher payment (=IF... ) to get this result
    C9-23:30 End time of higher payment (=IF... ) to get this result

    Also to make sure the formulas work if the working hours are between 16:00-25:02 break at 21:20-22:40, 21:30-29:50 break at 25:00, 24:01-31:00 or 23:40-28:00 breaks embedded at any time...
    I have tried this, but could not make it work.

    Will this take to much time to write formulas that makes this work?

    Best regards

    Tom S

  4. I need a formula that figures out how many entries in a range and then divides by that about of entries. Example if A1= 0, A2, = 3, A4=5 then divide by 2.

    Thank you for your help. I actually have 7 entries - 1 for each day of the week, and want to divide only by the days that actually have a number greater than 0. So what I need is the sum of the 7 days then divide by only the number that had an actual value greater than 0.

    Thank you!

    1. Hi Pauline, I hope you already received a response, but if not here's my answer. You would use the Countif function. It would look like this:
      =COUNTIF(B1:B3,">0") the function looks at the cells B1 to B3 and returns a number between 0 and 3 depending on how many of the cells have a value higher than 0.

  5. Que. If A1>B1 & C1=D1 then bonus will be (A1*0.002), but If A1>B1 & C1=D1 and F1>G1 & H1=I1 then bonus will be ((A1+F1)*0.002*2). Please suggest correct formula to be used?

  6. If I got many data to lookup, how to enter the data by using if formula?

    Ex: =if(A1>=1000,900,if(A1>=900,850........and so on)

    Please assist me, thanks.

  7. i need a formula for a completion time for each department for example IF any department goes 20 min ahead or behind produce which is F2 highlight Red if all departments are going to finish within 20 min of each other highlight Green my range is F2-F8

  8. Hi,
    I have a set of number in a columns from 12 to 30 & I want result for them in 2 word
    that can be more than 15 or less than 15. Is there a way I can get a formula result for these number. thank you

    1. Abdul:
      If I understand your question an IF THEN OTHERWISE statement will work for you. Where the first number is in A2 enter this in B2:
      =IF(A2<15,"Less Than 15","More Than 15")
      It says, if the value in A2 is less than 15 then display "Less Than 15" otherwise display "More Than 15".

  9. I have a column that has taken the difference between two columns.

    I want to extract any variances greater than 10K (so more than 10K or less than negative 10K) AND greater than 10% or less than negative 10%

    I just want it go return that number if both conditions are met - or return a blank

    What is the easy way to look at any difference more than a certain amount - whether that be negative or positive?

  10. Hi there,

    trying to write an excel formula for the following:-

    if a1 is greater than or less than b2 by more than 5% then colour cell? Any help would be greatly appreciated.

  11. I applied a formula like
    =A1
    then it shows whatever is there in A1 . But if A1 is blank then its showing 0 instead of blank.
    I want it blank if it is blank in A1

    1. Hello, Manu.
      Please try to apply the formula below instead:

      =IF(ISBLANK(A1), "", A1)

      Hope this is what you need.

  12. IF A1=25001 to 50000 & B1=yeas than C1=D1*10%, IF not match C1= 0
    IF A1=50001 to 75000 & B1=yeas than C1=D1*15%, IF not match C1= 0

  13. IF(E8>60<90,F8,0)

    THIS FORMULA NOT GIVEING MY ANSWER

      1. =IF((AND(E8>60, E84,R5<=4)),AE5,VLOOKUP(AE5,VALIDATION!$M$3:$P$24,4))

      2. great

  14. Hi
    I need kind help in this situation, i want excel formula:-

    "Percentage apply on
    Minimum " Maximum Tax amount Difference
    Amount Amount Fixed Minimum and Maximum"
    4,800,001 To 99,900,000,000 300,000 15.0%
    2,400,001 To 4,800,000 60,000 10.0%
    1,200,001 To 2,400,000 - 5.0%
    800,001 To 1,200,000 2,000
    400,001 To 800,000 1,000
    Zero To 400,000 -

    Note { Provided that where the taxable income exceeds Rs. 800,000/- the Minimum tax payable shall be Rs. 2,000/- }

  15. I have an IF statement that looks at one cell and depending on what "class code" I have in that cell it refers to another cell then adds that number into the calculation. This is working fine but I want it to then put 0 instead of a negative number. I tried adding If(<0,0,) but it is not working and I have tried several variations of less than zero. Any suggestions?

    1. Malissa:
      Can you post the formula that was working?

  16. Thank you for your response!

    The formula you offered of course works on that cell, thank you! But I am wondering if I have a whole column of say 3000 entries in column A with say 50 different words that I am looking to label, the IF statement will get very long.

    Excel suggests to use IFS statements instead of IF statements, but as you say, you can't use an IFS statement when searching for a substring.

    Trying to find a practical solution...

  17. 21080931
    21079882
    21079117
    21080035
    21234
    21225
    22225
    21228
    I WANT TO ADD DOT (.)AFTER 2 NUMBERWHICH LEN IS GREATER THAN 6 NO
    AND WHICH IS SMALLER THAN 5NO ADD ONLY 1 DOT (.)AFTER THE VERY FIRST 2 NO. PLEASE HELP ME
    EX=
    21.07.98
    21.07.9117
    21.08.0035
    21.234
    21.225
    22.225
    21.228

    1. 21080931 =IF((LEN(A1)<6),LEFT(A1,2)&"."&MID(A1,3,20),LEFT(A1,2)&"."&MID(A1,3,2)&"."&MID(A1,5,20))

  18. Charlie:
    As you have discovered an IFS statement won't work when you are searching for a substring within a string. However, using IF and SEARCH together along with ISNUMBER will produce the result you want.
    There are some fancier ways to get there and I will leave it to you to discover those on your own, but this is a simple method and it works just fine. Where TownPetShop8009898999 is in A89 enter this in B89.
    =IF(A89="","",IF(ISNUMBER(SEARCH("*PET*",A89)),"Pet Supplies")) Any string containing "Pet" will return "Pet Supplies".
    You can do the same with the CVS string.

  19. I would like to use an operator to identify a word contained in a phrase to create a list.

    Simple IFS formula can't seem to find a word in a phrase.
    Is there an operator for if a word is contained in a phrase?

    SPECIFICALLY:
    I am trying to label a list in a column, say column A. Each item in Column A contains a phrase. In column B I want to be able to label the phrase in column A based on whether it contains that word.
    For ex:
    Column A:
    A1: TownPetShop8009898999
    A2: CVSdrugs898474747

    Column B: I would like to label Column B as follows:
    If it's "Pet", it would enter "Pet supplies " in Column B
    If it's "CVS", it would enter "Pharmacy " in Column B

    The problem is that the entrees in Column A vary, but will contain the key words such as "CVS" or "Pet" mixed with other info that varies from cell to cell.
    Any ideas?

  20. Thank you so much!
    I came across your page while looking for a way to display a value only if A1-B1 is greater than zero and this worked perfectly!

    The logical formula was more appropriate in my case because it was for accounting. When I used the IF formula, a big fat FALSE was placed in all of the cells where the formula was false, whereas, with the logical formula, those cells displayed only a dash in the center.

    Thank you again!

  21. Hello
    I have tried to entered the following formula:
    IF(0<=H16<=8;H16;8)
    that when the H16 is greater to 8 it works (and results: 8) BUT when it is between the 0 and 8, the logical result is FALSE (!!!!) and results also 8!!!!

    Any idea?
    Thank you in advance.

  22. I NEED FORMULA FOR A function if we multiply (3*v33) is=f the value less than or eqaul to 150, then it should come 150 in BA36 column

    PLS HELP

  23. If cell A has 900,000 as value and Cell B returns varied value i.e 200,000, I want Cell C to record the difference between the addition of cell A & B only when the value is above 1000000. For example Cell C will record 100,000. If the value in cell B is 300000, then C will return a value of 200,000.
    Thanks

  24. HELP ME WITH THIS; =IF(A4>=14500+A4),IF(A4<14500+0

    1. Evarist:
      The statement in this cell is incomplete.
      Right now it says, If A4 is greater than or equal to 14,500 + A4 or if A4 is less than 14,500 and this is as far as the statement goes.
      What do you want to display in this cell?
      What are you trying to say with the statement?

  25. =(PROJECT.xlsx!WWC51_DOM)

    trying to use another sheet as a reference while using the a cell from the original sheet to dictate which cell data from the other sheet to pull.

    =(PROJECT.xlsx!('[ACESII Kit Time Change 1574.xlsx]sheet1'$A$1)_DOM)

    -project is the 2ed sheet
    -acesii time change is the original sheet. *this sheet is the sheet the formula will be placed in.*
    -the "_dom" is the last four characters of each cell name in the 2ed data sheet. ex (wwc51_dom) (wwc21_dom)
    - the second formula is the one i came up with but it isn't working. what i want is to use a cell from the original excel sheet to be my (WWC#), so that when i change the cell with the (WWC#) the formula placed on a different cell within the original sheet will display the WWC# information from the 2ed sheet.
    ex: cell will read WWC51_DOM *DATE* / when i change the WWC# to WWC21_DOM, it'll pull WWC21 dates.
    -1st & 2ed sheets are different excel documents
    -sorry for the complicated question if theres a better way or if you could fix this it'd be greatly appreciated. Thanks

    1. Danny:
      I think what you're trying to accomplish can be done via a VLOOKUP formula.
      Take a look at the articles here on AbleBits dealing with VLOOKUP or even INDEX/MATCH and see what you think.
      If you need help after that post another question with some sample data if you can.

  26. please help me about this

    when I set or input value in a cell I would like it to return its value to 0 when I hit enter and the data will be added to another cell which is the total in excel thank you so much in advance in your reply

    new value= 1(a1) total value= 10(a2) this is whats on my mind that will happened

    new value=0 (a1) total value= 11(a@)

    thank you in advance

  27. hi
    i want a formula for

    4515 to be rounded to near 90's or 150's as per the situation be

    eg, if i got 2030 then the formula should bring the answer as 2050, and if there is a value as 1010 then it should round it to 990

    if the value is more than 120 then it should round it to near it's 150s and if the value is less than 120 then it should round it to near it's 90's

    plz help

  28. Hi,

    I'm trying to compare two cells with equal $ values, but different formulas, with =A1=A2. Sometimes I get TRUE, sometimes FALSE.

    The $ values are definitely the same!

    Any help would be appreciated.

    Thank you

  29. I'm working on performance review spreadsheets and I need a formula that will show me:

    If >1 but 2 but <3 "Inconsistent to Proficient" and if = 2 ""Inconsistent" and if =3 then "Proficient"

    1. Jasmine:
      The logic isn't clear.
      Both 2 and 3 are greater than 1, so the formula will break.
      Should the first statement be:
      If cell value =1 then "Inconsistent to Proficient" ?
      Is there a score greater than 1 but less than 3 that is not 2?

  30. Sorry about that. Column F has to be able to determine whether a new amendment is needed and has to meet both column D & E criteria. When one is true in the formula below it gives a false positive I.e., amendment required. I have tried dozens and dozens of different formulas without any true success.

    =IF(OR(D4>10000,E4>20%,D4<-10000,E4<-20%),"Amendment Required","No Amendment required")

  31. Do not know why it cut some of question. The formula gives a false positive, need the formula to meet both requirements, not one.

    =IF(OR(D4>10000,D420%,E4<-20%),"Amendment Required","No Amendment required")

    1. Hello, OJ:
      You've posted two similar but different questions which one contains the correct logic you want to use?

  32. Good Afternoon, Thank you for this site. You have gotten me further than I ever thought I would get doing this.

    However, I am stuck on this formula. =IF(OR(D3>10000,D320%,E3 +/- 10000 AND > +/- 20% need a new plan.

    Any help would be GREATLY APPRECIATED!!!!!

  33. How do I set negative numbers in an IF function in excel? For example =IF(BK2-1)

    1. Elissa:
      Enter a negative number in a formula by enclosing it in a parenthesis, like this:
      =IF(A133<=(-1),"Neg","Pos")

  34. I have a problem, can you please assist.
    I need to calculate a value,
    Thus in words " if value A > value B and value A < value C; Return value D. This then needs to compare with 10 similar logical arguments, but only one answer can be correct.
    How should my formula look like if the only constant is value A.

    Regards

    1. Andre:
      Not exactly sure what you're looking for, but here's how you find the first part of your question. Where the values are in columns A through E.
      =IF(AND(A1>B1,A1<C1),D1,E1)
      In words this formula says, "If A1 is greater than B1 and A1 is less than C1 then return D1 otherwise return E1."
      This is as far as I can follow your question.

  35. Hi,

    I need help on the following excel IF statement in which if cell E1 is either Carbon or Alloy and then uder cells F1 thru to K1 is either between those numbers the it should come back as PASS otherwise it should be FAIL.

    =IF(AND(E1=”Carbon”, OR((F12.1,G11.5,H10.5,I0.3,J0.25,K11.5)),”FAIL”,IF(AND(E15=”Alloy”, OR((F11.5,G15,H11,I11,J15,K115)),”FAIL”,”PASS”))

    For some reason I have tried so many ways and still no luck in getting the words PASS or FAIL to be added to any cells.

    I would love your support on this.

    Thanks
    Adam

  36. Hi.
    I have a query related to if or might be nested if.
    The case is as below

    I have a calculated field for number of days (Cell A - Cell B)for e.g 150 and target is 180 days. The delta here is 30 days, it can be positive as well as negative. I want put a formula that would allow me to fix a range that number of to be multiplied by 2.5% and the result should not be more than 25% and should not go below -25%.

    Awaiting your support.

    Thanks

  37. Please give me formula of 10x5= 50

    1. Hey Joser

      You should write =10*5 and press enter

      Thanks

  38. IF A2= Amanda and E2=2/13/18, and I have information put on another sheet that changes weekly. How do I change E2 to the newest data, but keeping it only to A2? Mind you data in the other sheet is not always in same order, so it would have to find it.

  39. Hello,

    I am struggling with a formula to look at a field containing the time of an accident report after the event. I am trying to get information of 4 ranges of time taken. 0-10 days, 11-30 days, 41-60 days and 70+ days.

    There is another field that has the team names in it and ideally ide like to have a breakdown of how many times a team has submitted reports late and by how many days from the 4 ranges above.

    Many thanks

    M

  40. Here we go - I have a simple formula that I am using:

    =IF(F2>=K2,"yes","no")

    What I need is to make K2 a constant. I've tried making it an absolute (ABS), but I think I'm just not putting it in the right place in the equation. One, it's a fixed number in the spreadsheet, and two, it will prevent the formula from going to K3,K4,K5,etc as I pull it down.

    Any help would be great.
    -PK

    1. Hi!

      Why not simply use an absolute reference? :)

      =IF(F2>=$K$2,"yes","no")

    2. Aha! I got it figured out. I was trying too hard. Thanks, though!

  41. how do I find matches between column's. column a contains 5000 items and column b contains 6000.

  42. Its working
    Thanks.

  43. Hi,

    If A5 is less than 10 then value become in B5 should be 0
    And if If A6 is 11 then value become in B6 should be 50
    And if A7 is 12 then value becomes in B7 is 100.

    Please help.

  44. Hi,

    I have used the "or" function to test missing fields, with a output of True or False. True if required fields are entered and False if any of the Fields are missing. I would like to know if there is way excel can List which fields that are missing which result in the False output

  45. I want to learn a formula for
    if A1 is greater then B1 then show the result in C1 and but A1 is less than B1 than 0 or Nill will show in C1

    i am trying
    =if(A1>B1,A1-B1,Nill)
    But its not working

    Could you help me out.
    Thanks In Advance

    1. Hi Noor,

      Please put the text value in your formula in double quotes or replace it with 0, i.e.:

      =IF(A3>B3,A3-B3,"Nill")

      Or

      =IF(A3>B3,A3-B3,0)

      Hope this will help.

  46. Good day

    What is the formula for: if F2 is smaller than or equal to 40 then subtract 5 from F2 and if F2 greater than or equal to 50 add 10 to F2.

    Regards
    M

  47. Desperate for help. Have a spreadsheet in which complaints have been given numerical value. How do I get the actual text value to come up in a new column?

    Complaint
    1 Broken Tube (pre-meal)
    2 Broken Tube (post-meal 1st hr)
    3 Broken Tube (post-meal 2nd hr)
    4 Broken Tube (post-meal 3rd hr)
    5 Broken Tube (post-meal 4th hr)
    6 Patient Nausea
    7 Missing Spirulina/Egg
    8 Missing Mixing Cup
    9 Missing Straws
    10 Missing Utensils
    11 Missing Crackers
    12 Missing Water Cup
    13 Missing Test Req Form
    14 Unpleasant Taste
    15 Patient Vomited
    16 Prescription/Medicine Interaction
    17 Data Transfer Issue
    18 Gastro Intestinal Issues (burping)
    19 Broken tube return shipment (Multiple)
    20 Barcode Mismatch
    21 Missing Return Label
    22 Missing Breath Tube
    23 Discrepency In Reporting

    So that if a line item notes for instance that complaint number 22 was issued, then in cell K3 Missing Breath Tube would show... and exclude all others.

  48. =IF(J8>89,”A”,IF(J8>79,”B”,IF(J8>69,”C”,IF(J8>59,”D”,”F”))))

    is this formula correct?

    1. Hello, Colin,

      Yes, your formula looks absolutely correct.

      If it doesn't work, then please send us your workbook with the data and formula to support@ablebits.com. I kindly ask you to shorten the table to 10-20 rows/columns and include the link to your blog comment.

      We'll look into the issue and try to help.

  49. Dear sir
    Que.1

    A<b (A*3/100)

Post a comment



Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)