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 4. Total comments: 713
Hi,
Need some help:
Want to leave H3 blank if K3 is less than 1.
Want to use calculation =K3*1.2-G3 if K3 is greater or equal to 1
What I have so far:
=IF(K3>+,"",(K3*1.2-G3))
Hi Derek,
Try this one:
=IF(K3<1, "", K3*1.2-G3)
Hye,
How if I want put two string condition? I'm using this [=AND ($Q9="Open" + $I9="A")] but its not working.
refer to: 3. Logical operators in Excel conditional formatting
Hi Aqilah,
Here's the correct syntax:
=AND($Q9="Open", $I9="A")
Having trouble getting a formula to work that will give me an outcome for a number between two values, tried this but no luck, what am I missing:
=IF((A1<=100),11,0)+IF(100.1<=A1<=140,12,0)
I want it to show "11" if the number in A1 is less than or equal to 100, I want it to show 12 if between 100.1 and 140.
Thanks.
Never mind the last post, I figured it out.
Thanks,
Avon
Hi I too am trying to solve this may I ask how you did it
Thanks
Hi Chris,
You can use nested if's, like this:
=IF(A1<=100, 11, IF(A1<=140,12,0))
Hi All,
I have the following problem:
A2=First name, B2=Last name, B3=Full name - for example:
A2=Joe, B2=Hart, B3=Joe Hart
What i need is if B3 contains B2 = OK - unfortunately i can only find the exact formula but not an partial recognition.
Hope you can help me somehow. Thanks
Hello Joe,
The IF function does not recognize wildcard chars, therefore you have to use isnumber/search like this:
=IF(ISNUMBER(SEARCH(B2,B3)), "OK", "")
hello mam,
when we can use
if(exact(cell 1,cell 2),"true value","false value")
formula or drag the mouse than both cell value increase but i want only cell 2 value increase or cell 1 stable.
thanx
Hello BRIJESH,
To fix a cell reference, put the $ sign in front of the column letter and row number, like $A$1. For the detailed explanation about absolute and relative cell references, please check out the following tutorial: Why use dollar sign ($) in Excel formulas
please help,
can u give the formula,, my problem is, 1f the cell A is less than .5 the result should be, "NOT CORRECT" statement, but if cell A is higher .5 the result is CORRECT
Hello Axel,
Here is the formula:
=IF(A1<5, "NOT CORRECT", "CORRECT")
IF (E11:E:26<299999,"1500",600000,"5000")
Not sure why it changed my formula
Hello Heather,
Our blog engine sometimes mangles formulas in comments, sorry for that.
As for the IF formula, write it for one cell (E11) rather than for a range, and then copy the formula down to other cells. If you use relative cell references (without the $ sign), Excel will properly adjust the formula for each row. So, here goes the formula:
=IF(E11>=600000, 5000, IF(E11>=300000, 3000, 1500))
hello
I need a pretty complicated formula.
We deal with traveling nurses and their hours and housing.
I'm needing to know how to calculate if cell A is equal to or great than cell B then cell C stays the same. But is cell A is less than cell B then cell C will be lowering.
So, if cell A is less than B the equation we use (on paper lol) is A/B=Total then we take the total x C = The actual total I'm needing
Hello Liz,
If my understanding of the task is correct, you can use the following formula:
=IF(A1>=B1, C1, A1/B1*C1)
HI,
I'm trying to create a formula to ask(if a1=1 & b1=2 return the contents of b16. Please help.
Thank You
Hi Frank,
Here you go: =IF(AND(A1=1, B1=2), B16, "")
Thank You Svetlana for the swift reply.
I have 10 variables in cell A1 and 3 variables in cell B1.
How do I include any variation of them in cell B16.
The 10 & 3 variables are already in a drop down list
The formula in your reply works well for a single variation.
Thank You again
Need help figuring out how to write a formula in Excel 2016.
I need to have the following formula's answer round up to 3 if it is less than 3.
=SUM((B16/12)*(C16/12))
Hi Sara,
Try this one:
=IF(SUM((B16/12)*(C16/12))<3,3,SUM((B16/12)*(C16/12)))
Can you please give me a formula for depending on which date is greater than another. 180 days will be added to the greater than date. Thanks!
Hi James,
You can use a formula similar to this:
=IF(A1>B1, A1+180, B1+180)
Where A1 and B2 are the dates to compare.
I just want to rounded up to next 10 but will remain neasest integer if the unit place is 0.As for example: 187.6.1 will 190 and 120.3 will 120.
Hi Puspen,
Try this one:
=IF(RIGHT(TRUNC(A1,0), 1)*1<>0, CEILING(A1, 10), INT(A1))
Hello, thanks for the great article.
I have a simple question. I have the word "test" in A1 and the formula "=A1>0" in B1. B1 shows "TRUE". How can "test" be greater than zero? I would expect some kind of error message instead of "TRUE".
Hi John,
In Excel any text including an empty string ("") has a higher value than any number. To return an error message for text values and blanks, you can use a formula similar to this:
=IF(AND(ISNUMBER(A1), A1>0), TRUE, IF(ISTEXT(A1), "error: text", IF(ISBLANK(A1), "error: blank")))
Hopefully you can help me out, I need to subtract 15 minutes when a value (A1) duration is below 6 hours and 30 minutes needs to be subtracted when the value is above 6 hours.
You could help me out by getting the value 0:15 or 0:30 in a cell so I can subtract the values.
thank you in advance
Hello Jacy,
Try this formula:
=IF(A1<TIME(6,0,0), A1-TIME(0,15,0), A1-TIME(0,30,0))
For more information, please check out this article: Adding and subtracting time in Excel.
can someone help me how to Use a formula to define the age as given below.
>=80 is ""Old"", >=60 to =35 to <59 is ""Middle"", <34 is ""Youth""."
Hi BK
the conditions which you have given are confusing
assume that the conditions look like
than you can use this formula
Age should be 60-80 then old
35-60 then middle
below 35 youth
=IF(AND(A1>=60,A1<=80),"Old",IF(AND(A1>=35,A1<=60),"Middle",IF(A1<35,"Youth"," ")))
hope this is helpful
-Svetlana,
Great site- thanks for such a great resource!
I'm trying to create formula to show when a cell/number/Sum is higher than 42.5, then show that number in decimals. Can you help please?
Hi Fred,
Thank you for your kind words. I am not sure I fully understand your goal. Do you want to display no decimal places for numbers less than 42.5 and a certain number of decimal places, say 2, for numbers greater than 42.5? If so, you can use a formula similar to this:
=IF(A1<=42.5, ROUND(A1,0), ROUND(A1,2))
Instead of ROUND you can use any other Rounding function as your business logic requires.
If you are looking for something different, please clarify.
Hi Svetlana,
Please help me.. my requirement are:
condition=> =if(and(z9>=j10,z9 z10=i10
or else=> z10="v"
my current formula is =if(and(z9>=j10,z9<=k10),"wd","v"))
where it is fine, but I want to reconstruct that "wd" or cell value appear to z10 is dependent to cell value of i10 (where I can enter either "wd" or "wn" from cell i10 but will appear to z10 once satisfy the condition if.
Please note z9,j10,k10 are date format; and z10,i10 are text format.
Many thanks!
Marlone
Hi Svetlana,
Good day!
I figured it out the correct syntax that I needed. I inspired with this blog and reviewed old comments until I got an idea and executed it, then it works...Good luck and thanks, you have a very helpful blog!
Thanks and Regards!
Hi Svetlana,
i need when:
h2>8 and i2>123900 then k2give (good)
h2=8 and i2=123900 then k2 give(ok)
h2<8 and i2<123900 then k2 give (0)
many thanks
Hi Majed,
Here's the formula for K2:
=IF(AND(H2>8, I2>123900),"good", IF(AND(H2=8,I2=123900), "OK", IF(AND(H2<8,I2<123900), 0, "")))
how to add farmula
if B3>12 then + 500 ???
how ???????
kindly make farmula
Hi Benson,
You can use a formula similar to this:
=IF(B3>12, B3+500, "")
Hi Svetlana,
The values of column Q are 100, 99.71, 99.21, 94.99, 80.00 & in some places it is <70.
I want the result in column R like, IF Q=100, R = 2, IF Q is b/w 99.99 to 99.50, R = 1.6. If Q is b/w 99.49 to 95.00, R = 1.2. IF Q is b/w 94.99 to 90.00, R = 0.8. If Q is <70 then R = 0.
Please help me with the formula to capture the required value.
Hello Shashikumar,
You can use the following nested If functions:
=IF(Q1>=100,2, IF(Q1>=99.5, 1.6, IF(Q1>=95,1.2, IF(Q1>=90, 0.8, IF(Q1 >=70,0.6,0)))))
You didn't not specify R for Q b/w 70 to 89.99, and I added 0.6. Just replace it with the right value in the last IF statement.
Hi Sveltana,
I am trying to match with an if function the foloowing:
if (item1=y,"y","n")
But then I'm getting error Name?
Thanks,
Item 1 Item 2
Y
Y
Y
Y
Y
Y
Y
Hi Mona,
Try the following formula:
=IF(A2="y", "y", "n")
Where A2 is the first cell of the Item 1 column.
l need help on if the value greater than 50 subtract 30 and is less than 50 add 10
Hi Shylet,
Here you go:
=IF(A1>50, A1-30, A1+10)
I need help with a formula for a commission grid for my sales team.
I'm trying to get the following answer from the formula.
IF cell G34 is less than 29939.99 = blank
IF cell G34 is greater than 4500 - blank
IF cell G34 is greater than 3000 but less than 4499.99, multiply G34 x D37
Thanks in advance for your help...
Hi Charles,
Try the following formula:
=IF(AND(G34>=3000, G34<=4500), G34*D37, "")
Hi,
If a cell is having some text & some country name then how can i get only country names in a second cell. I know the exact spell of the country name.
Hello Vaibhav,
The formula depends on your data pattern. For example, i.e. all cells contain some text, followed by a single space, followed by a country name (like text USA, then you can use the following formula:
=RIGHT(A1,LEN(A1)-LEN(LEFT(A1,FIND(" ",A1))))
If your data has some other pattern, please provide a few examples, and we will try to work out a proper formula.
Hi Svetlana;
i have the following excel exercise and i need your assistance;
1.Number Student passes B5=40,B6=25,B7=32,B8=48
2.Life guards allocations are as follows;
Student pass ranges: 0-30 = 2 life guards, 31-60= 4 life guards,61-90= 6 life guards,150+ = 12 life guards
Assume the Number of Lifeguards needed in a day depends on the number of Student passes for that day as given above. Use an appropriate formula to determine the expected number of lifeguards for each day to go into a separate column called Number of lifeguards. Hint: Vlookup formula.
Please provide the Vlookup formula or some formula i can use in my excel.Thanks a lot in advance.
Have the >= and =0.93,"A",=90,"A-",=87,"B+",= 83, "B",=80,"B-",=77,"C+",=73,"C",=72, "C-", <70,"YOU FAILED")
It's for a grade calculator, in which E24 is the grade as calculated by points earned divided by possible points. Anyone see my error? Psyched about this new SWITCH function.
Okay, that didn't post right...What I meant is have the = functions been incorporated into the SWITCH function yet? That formula is NOT what I had. It was a lot more complicated than that and had a lot of operators in it. Oh, well! Cest la Vie!
what is the formula for "condition if F4 IS EQUAL TO OR MORE THAN 100 USE 70 OTHERWISE USE THE SAME VALUE IN F4
Hello Belal,
Use this formula:
=IF(F4>=100, 70, F4)
what is the formula for "condition if Column A is more than Column B, use Column A-Column B*0.40"
Hello Mahesh,
Here you go:
=IF(A1>B1, A1-B1*0.40, "")
what is the formula for "condition if Column A is more than Column B, use Column B"
Hi Charlie,
You can use a formula similar to this:
=IF(A1>B1, B1, "")
Hello friends,
I am struggling with a formula. please help me out.
If a cell value is greater and less then a given value then "OK" and "Not ok"
for Example. IF cell A2 is greater then 12 but less then 22.8 . If cell A2 meet this criteria then "Ok" otherwise "Not Ok".
Thanks
Hi Sumit,
You can use the following formula:
=IF(AND(A2>12, A2<22.8), "OK", "Not OK")
IF Cell A=Apples and cell B10 but 20 but <30, then return cell C=500. IF cell A=Grapes and cell B10 but 20 but <30, then return cell C=300.
I don't know why I'm not able to publish my complete question. there is more to the above logic that I'm looking to add.
***HELP!!***
I need a formula for the following. It's kind of a multi-step process:
1. If A1=A2 and B1=B2, then return value TRUE.
2. If A1=A2 and B1B2, then return value FALSE.
3. But if A1A2, then disregard formula/leave blank.
I meant to say:
1. If A1=A2 and B1=B2, then return value TRUE.
2. If A1=A2 and B1 doesn't equal B2, then return FALSE.
3. But if A1 doesn't equal A2, then disregard formula/leave blank.
I know it's confusing, but I ONLY want the B values to equal each other if the A values are equal... If the A values aren't equal, then I want the B values to forget that command and revert to only like values...Here's an example of what I mean:
A1:A7 all have the same value. If B1=B2=B3...=B7 then great! If B1:B7 DON'T have equal values, then I need an error notice. After A1:A7, there is another group of DIFFERENT like-values...A8:A15. For all of these, I need B8=B9=B10...=B15. If they don't, I need an error. Hope that helps.
Cameron,
My previous formula works for 2 cells only (A1 and A2). To compare groups of 7 cells, try the following one:
=IF(AND(COUNTIF($A$1:$A$7, $A1)=7, COUNTIF($B$1:$B$7, $B1)=7), TRUE, IF(AND(COUNTIF($A$1:$A$7, $A1)=7, COUNTIF($B$1:$B$7, $B1)<>7), FALSE, ""))
If cells A1:A7 have the same values and B1:B7 have the same values, the formula returns TRUE.
If cells A1:A7 have the same values but B1:B7 have different values, the formula returns FALSE. You can change this to any error message you want.
Otherwise, the formula returns an empty string.
Hi Svetlana!
Thank you so much for your quick replies. When I tried to enter this last formula, it gave me a notice for a circular reference? I clicked ok, and the formula returned a zero. Any ideas what this means/how to fix?
Secondly, I have an even more complex question for you (if that wasn't already hard enough). What if my first group is A1:A7 but the next grouping is A8:A18? What if it isn't always groups of 7, but it varies group size randomly down column A? Is there any way I can enter a formula to predict this, and always have the corresponding B values equal? (Where B1:B7 are equal and then B8:B18 would be equal, etc.) Again, I just need the formula to return True or False for these groupings. Thanks!!
Hi Cameron,
Try the following formula:
=IF(AND(A1=A2, B1=B2), TRUE, IF(AND(A1=A2, B1<>B2), FALSE, ""))
I am struggling with this simple task .. can you pls help ?
I have an excel sheet with over 20,000 products with weight in decimals. I am trying to do this :
if weight is greater than 0.00 and/equal 1.0 then "0-1 lbs"
If weight is greater than 1.10 and/equal 2.00 then "1 and 2 lbs"
I am using =IF(AND(A2>0,A2<1),"0-1 lbs","") but this is not working for decimals
examples :
Weight (lbs)
0.10
0.01
0.02
0.03
0.04
0.05
0.06
0.07
0.08
0.09
0.10
0.11
0.12
0.13
Hi Vinay,
Try this one:
=IF(AND(A2>1.1,A2<=2),"1 and 2 lbs", IF(A2>0,"0-1 lbs",""))
the formula type out wrong...
it's
=IF(B18011200;40%*B1)
Hi Celeste,
Our blog engine often mangles formulas in comments, sorry for that.
Try the following formula:
=IF(B1>=1201; 40%*B1, IF(B1>=801; 30%*B1; 20%*B1))
It worked! Thank you Svetlana!!!
I need a help guyz..for eg when x>20 should proceed with a formula or when x<20 takes the other.please help me to create a formula buddies
What formulas you want to see when one of the conditions is met? Also, is 'x' in 'x>20' is a cell reference? Give us more details, so we would be able to help you out.
I want to multiply 2 cells, A11 and L11, but if the product is <=0 I want to enter Cell A11.
Hi Marlone ,
Try the following formula:
=IF(A1*L11<=0, A11, A1*L11)
Problem with conditional formatting using greater/lower than:
how do I skip a blank cell and compare with the previous cell?
Example: A1= 5, B1= blank, C1= 2
I need to know if C1 is greater/lower than B1, but if B1 is blank then I want to skip B1 and instead get result for C1 greater/lower than A1. What formula do I use to do this?
Thanks in advance!
Hi Niksua,
You can create 2 conditional formatting rules with the following formulas:
If B1 is not blank, highlight C1 when it's greater than B1:
=AND($B1<>"", $C1>$B1)
If B1 is blank, highlight C1 when it's greater than A1:
=AND($B1="", $C1>$A1)
Looking for how to return a value for a number that falls within certain ranges. For example:
If H10 is greater than 750, return 1
If H10 is between 650 and 749, return 2
If H10 is between 550 and 649, return 3
If H10 is less than 550, return 4.
So that if in cell H10 a number is entered, then in cell H11 a value of 1, 2, 3 or 4 will be displayed.
Any help would be appreciated. Thanks!
IF(H10=>750,1,IF(H10=>650,2,IF(H10=>550,3,4)
Suppose A1=A+B+C+D & A2=B+A+D+C , i apply =exact(A1=A2) but result is "False".
In Excel any other function for this. Reply me as early as possible.
Thank you...
Hello Bhanu,
EXACT is the right function for this task. Just note, the correct syntax is =EXACT(A1,A2)
You can test it in the following way. Enter some values in another column, say column C, and then type the following formulas:
In cell A1: =C1+C2+C3+C4
In cell A2: =C2+C1+C4+C3
Then enter the formula =EXACT(A1,A2) in some cell, and it will return TRUE.
I'm going crazy on this..
I need to create a conditional formatting meeting several criteria.
If a1>0 and = d1 OR b1>0 and = c1
Hi Mauriccio,
Try creating a conditional formatting rule with the following formula:
=OR(AND($A1>0, $A1=$D1), AND($B1>0, $B1=$C1))
previous post was incorrect
IF((C7>72700,9,"0"),IF(C7>227425208012143916<208012,2,"0"))
Need help with this formula
Vehicle and odometer readings
If cell C7 is 72700 or higher it is vehicle 9
227425 or higher 5
208012 or higher 21
143916 or higher 2
Hi!
You need to use nested IF functions and the correct syntax is as follows:
=IF(C7>=227425, 5, IF(C7>=208012, 21, IF(C7>=143916, 2, IF(C7>=72700, 9, 0))))
Hello,
Thank you for your prompt response. I very much appreciate it!
I need to create a function based on a decimal place
ex. 7.341, if the the decimal value is greater or lesser than .4, the value of "7" would be unknown lets say, if the number has a decimal point equal to .4 or greater the value of "7" stays the same, if the number has a decimal point of .39 or less than, we will subtract 1 from the "7". How do I put this into a function especially since the value is dependent on decimal points.
Hi Justyna,
If my understanding of the task is correct, one of the following formulas should work a treat (where A1 is the decimal number).
Return a decimal number:
=IF(A1-TRUNC(A1,0)>=0.4, A1, A1-1)
Return an integer:
=IF(A1-TRUNC(A1,0)>=0.4, TRUNC(A1,0), TRUNC(A1,0)-1)
I'm trying to create a formula to automatically compare two scores and return whether the game was a win, loss, or tie for the team in question. I understand how to handle just wins and losses [for instance, =IF(BS10>BR11,"W","L")], but the possibility of a tie complicates things. I've tried using the IF formula with the if true value set to "T" and the if false value as the equation above, but it is invalid. Is there a way to do this?
Hi Jake,
I think you can use the following nested IF's:
=IF(BS10>BR11,"W", IF(BS10<BR11, "L", "T"))
Hi,
can you help me our please
if G3 is greater than H3 I want to have these 2 cells to be subtracted as G3-H3, if G3 is lesser than H3 I want to have these 2 cells to be subtracted as H3-G3
i had used the below formula but error occurred so can you help me please
=IF(G3>H3),"G3-H3",IF(G3>H3),"H3-G3"
How would you type an IF statement for a cell that is equal to 50 , 500, or 550 to be multiplied by formula x but for all other values to be multiplied by formula y.
Hi Taquana,
You can use a formula similar to this:
=IF(OR(A1=50, A1=500, A1=550), A1*x, Z1*y)
Hi Svetlana,
i need value in H2 = E2 when it< or = the value in G2
if this value greater than the value in G2 then the value in H2=the value in G2
THANKS,
Hi Majed,
Here's the formula for H2:
=IF(E2<=G2, E2, G2)
Many Thanks Svetlana,
in need:
L9 = 3000 if k9=(100% to 120%)
L9=4000 IF K9 =(121%-130%)
L9=5000 IF K9 greater than 131%
J8= 0% IF E8=(0% TO 50%)
J8= 10% IF E8=(51% TO 60%)
J8= 15% IF E8=(61% TO 80%)
J8= 20% IF E8=(greater than 81%)
Best Regards
Majed
Hi
I wonder if you could help me please, I need to set up a formula which will allow me to charge based upon numbers;
i.e
100 or less = £35
101 to 200 = £45
201 to 300 = £55
301 to 400 = £65
401 to 700 = £75
701 to 1000 = £100
Many Thanks,
Hello Susan,
You can use the following nested IF functions:
=IF(A1>700,100, IF(A1>400,75, IF(A1>300,65, IF(A1>200,55, IF(A1>100,45,35)))))
Hi Svetlana,
Happy Holidays! I would like to know if you would be able to help me with my request no. 248, above. I appreciate it very much!
Sincerely,
Lorena
Happy holidays to you too, Lorena!
You can use the following nested IF functions (where A1 is total points):
=IF(A1>359, "A", IF(A1>319, "B", IF(A1>279, "C", IF(A1>239, "D", "F"))))
You can find the detailed explanation of the formula's syntax and logic in this tutorial:
https://www.ablebits.com/office-addins-blog/nested-if-excel-multiple-conditions/
Thank you so much, Svetlana! I am looking forward to trying this.
Sincerely,
Lorena
Please help.
This is my problem:
start time 08:00 am End time 19:00 pm
Start time 18:30 pm End time 22:00 pm
If the shift starts after 18:00 or ends after 18:00 a night allowance of R15,00 is payed.
How do I do this function.
this is what I have come up with ,but what I need is c2(start time) or d2(end time)is greater than 18:00 then the allowance needs to be paid.
=IF(C2>0,75;G2+15;G2)
Hi Lance,
If C2 and D2 are time values, you can use a formula similar to this one:
=IF(OR(C2>TIME(18;0;0); D2>TIME(18;0;0)); G2+15; G2)
Hi Svetlana
I mean to say, for example if I receive 10 items in "QTY RECEIVED" in Col-A and issue 11 items in "QTY ISSUED" in Col-B then your formula is showing -1 in "QTY BALANCE" in Col-F, I want that is should also show "error" in stead of -1.
Thanks
Asad
Hi Asad,
Here you go:
=IF(AND($B2<=$A2, SUM($C2:$E2)=$B2), $A2-$B2, "error")
Hi
How to check greater than 30 but less than 60 in a cell. Imagine value is in Cell A1.
Hi Ihsan,
You need to use an AND statement like this: AND(A1>30, A1<60)
For example, =IF(AND(A1>30, A1<60), "OK", "Not OK")
Hi Svetlana
can you please help me about find out formula against my Question No. 246, I will really appreciate.
Thanks
asad
Hi Asad,
If my understanding of your task is correct, the following formula should do a trick:
=IF(SUM($C2:$E2)=$B2, $A2-$B2, "error")
Hi Svetlana
Thanks a lot for your help, it is almost done, formula is working except a little more help, if value of column A and B does not match then it should also show error.
Thank you again.
Asad
Hi Asad,
My understanding was that A and B can be different values, because we calculate their difference. Please clarify what you mean by "A and B does not match".
i want compare Column F2 & E2 for 10% difference and display it fg in windings3 in column C hoow can this be achieved?
This is what i have at the moment.
=IF(F2=E2*0,9,F2<=E2*1,1),"fg","i"))
=IF(F2=E2*0,9,F2<=E2*1,1),"fg","i"))
Hi!
You probably meant this one:
=IF(AND(F2>=E2*0.9,F2<=E2*1.1),"fg","i")
Alternatively, you can embed the percentage change formula in the logical test:
=IF((F2-E2)/E2<=0.1,"fg","i")