Need help fixing an IF(AND statement in excel - excel

I am a beginner at using Excel and I've been trying to code a particular condition. The condition is as follows,
If A<75 and B<75 then do nothing
If A>75 and B<75 then A-75
If A<75 and B>75 then B-75
If A>75 and B>75 then (A-75)+(B-75)
Here, A and B are numerical values in two different cells.
So I wrote a formula and it works when the IF statements are not nested. However when I combine the formula it gives me an error. The formula I wrote is as follows.
=IF(AND(S180<75,V180<75),0,"-",IF(AND(S180>75,V180<75),S180-75,"-",IF(AND(S180>75,V180<75),S180-75,"-",IF(AND(S180>75,V180>75),(S180-75)+(V180-75),"-"))))
The formulae that work are as follows,
=IF(AND(S180<75,V180<75),0,"-")
=IF(AND(S180>75,V180<75),S180-75,"-")
=IF(AND(S180>75,V180<75),S180-75,"-")
=IF(AND(S180>75,V180>75),(S180-75)+(V180-75),"B")
I want the conditions to all be applied in a single cell so that I can switch the resulting value into standard values from another table using the =switch function. I am using Excel Online. Any help fixing my formula is welcome.
Thanks in Advance!

With IF, but could be shortened:
=IF(AND(S180>75,V180>75),S180+V180-150,IF(AND(S180>75,V180<75),S180-75,IF(AND(S180<76,V180>75),V180-75,IF(AND(S180<75,V180<75),""))))

Do you have a recent version of Excel with the IFS function?
=ifs(AND(S180<75, V180<75), 0, AND(S180>75, V180<75), S180-75, AND(S180>75, V180<75), S180-75, AND(S180>75, V180>75), (S180-75)+(V180-75), TRUE, "B")
If you try this formula and end up with a #NAME? error then your version does not support IFS.

Try this nested IF ,
To nest IF you need to include another IF in the FALSE condition of the first IF
=IF(AND(S180<75,V180<75),0,IF(AND(S180>75,V180<75),S180-75,IF(AND(S180>75,V180<75),S180-75,IF(AND(S180>75,V180>75),(S180-75)+(V180-75),"-"))))

Related

COUNTIFS with OR condition giving #SPILL! as a result

I've got the following formula
=COUNTIFS(MachineData!N:N,{"*Arlington*","*RenewNorfolk*"}, MachineData!$X:$X,"Y",MachineData!$E:$E,"<>*rinse*", MachineData!$C:$C,">="&$O$15-30, MachineData!C:C,"<="&$O$15+0.999988)
On the very first part of the formula I am trying to say "Count if MachineData!N:N is either like Arlington or like RenewNorfolk" but for some reason that specific part of the formula is giving me problems. Can someone help me figure out what the issue is with my syntax? Thank you
As explained here, using the *IF(S) type of functions with arrays will make them return an array, so you need to use SUM to get one value.

Nested if/then statement syntax

I've been reading a bunch of answers around nesting if/then statements in Excel but I can't figure out how to fix a "formula parse error" in mine. From what I can tell and in my code editor the formula is correct. Any ideas what I'm missing here?
I have a row of cells that auto-generate a number 1-35 based on other values. I want the cell with the formula to pull data from another row based on what's the in row of numbers 1-35. It works when I test one at a time; it's the nesting that is causing the errors. Thanks!
=IF(E$167=1,C56,IF(E$167=2,D56,IF(E$167=3,E56,IF(E$167=4,F56,IF(E$167=5,G56,IF(E$167=6,H56,IF(E$167=7,I56,IF(E$167=8,J56,IF(E$167=9,K56,IF(E$167=10,L56,IF(E$167=11,M56,IF(E$167=12,N56,IF(E$167=13,O56,IF(E$167=14,P56,IF(E$167=15,Q56,IF(E$167=16,R56,IF(E$167=17,S56,IF(E$167=18,T56,IF(E$167=19,U56,IF(E$167=20,V56,IF(E$167=21,W56,IF(E$167=22,X56,IF(E$167=23,Y56,IF(E$167=24,Z56,IF(E$167=25,AA56,IF(E$167=26,AB56,IF(E$167=27,AC56,IF(E$167=28,AD56,IF(E$167=29,AE56,IF(E$167=30,AF56,IF(E$167=31,AG56,IF(E$167=32,AH56,IF(E$167=33,AI56,IF(E$167=34,AJ56,IF(E$167=35,AK56,””)))))))))))))))))))))))))))))))))))
You might have run into a function nesting limit. Try the choose function to work around it.
How about using
=IF(AND(E167>0,E167<36),OFFSET(B56,0,E167),"")
Note : OFFSET is a volatile function, see this for details.
A simple vlookup or hlookup function can do exactly what you need without righting long nested if statement.
for example you can use:
=vlookup(E$167,$A1:$B35,2,false) where $A1:$B35 is the table array containing column A (1-35) and column B its corresponding value.

"IF" formula in excel using multiple conditions

I need help with an "IF" formula in excel using multiple conditions. This is what I need:
IF (cell) is <201, then *$2, if (cell) is 201-400, then *$1.15, if (cell) is >400, then *$1)
I am trying to create a "settlement" spreadsheet.
You may try this:
=IF(A1<201,"2",IF(AND(A1>201,A1<400),"1.15",1))
However, you've not mentioned what do you want to do when cell value is 201. If you want it to result in $2 then change formula to A1<=201 or else if you want it to result in $1.15 then write A1>=201 and same aplies to 400.
EDIT :
=IF(A1<=200,"2",IF(AND(A1>200,A1<=400),"1.15",1))
How many IF statements are you needing to string together? You are on the right track, they just get confusing the more you need to string together.

Check if a range contains a value > 0 in excel

In excel, i would like to check this range B2:G2, whether any cell within this range contains a value > 0, then it will returns True, else False.
Is there an excel formula that can help to achieve this? Before i am asking this question, tried different approach but no help such as: counta, sumproduct...
The MAX() formula can be applied to a range. Therefore, =MAX(B2:G2)>0 will give you your answer.
Yes! There is an excel formula to achieve this.
=IF(COUNTIF(B2:G2,">0"),"True","False")
Source: https://exceljet.net/formula/value-exists-in-a-range
Well if you don't want to use VBA the code below will work (although it is ugly ...)
=IF(AND(ISNUMBER(B2),B2>0),TRUE,
IF(AND(ISNUMBER(C2),C2>0),TRUE,
IF(AND(ISNUMBER(D2),D2>0),TRUE,
IF(AND(ISNUMBER(E2),E2>0),TRUE,
IF(AND(ISNUMBER(F2),F2>0),TRUE,
IF(AND(ISNUMBER(G2),G2>0),TRUE,FALSE))))))
It is just a bunch of nested if functions but it gets the job done

Nested if formula (Excel)

Hi I am trying to write a formula where if cell (J$4) = 1120 then it would run one statement, whereas if cell (J$4) = 1120s it would run another. I am using index-match to lookup the appropriate value. However, I can't seem to get my formula to work and I was wondering if you guys can find my error. The error is 'you've entered too many arguments for this function'. Any help would be appreciated! Thank you!
formula:
=IFERROR(IF(J$4="1120S",INDEX(B1HY3!$A$3:$F$300,MATCH("L 22a",B1HY3!$F$3:$F$300,0),5),IF(J$4=1120,INDEX(B1HY3!$A$3:$f$300,MATCH("L 22a",B1HY3!$f$3:$f$300,0),5)+INDEX(B1HY3!$A$3:$F$300,MATCH("L 22b",B1HY3!$F$3:$F$300,0),5),0),0)
Always try to follow parentheses' colors it is quite useful when handling with large formulas,furthermore try always to evaluate your formulas to check where the error is.
It worked for me:
=IFERROR(IF(J$4="1120S",INDEX(B1HY3!$A$3:$F$300,MATCH("L 22a",B1HY3!$F$3:$F$300,0),5),IF(J$4=1120,INDEX(B1HY3!$A$3:$F$300,MATCH("L 22a",B1HY3!$F$3:$F$300,0),5)+INDEX(B1HY3!$A$3:$F$300,MATCH("L 22b",B1HY3!$F$3:$F$300,0),5))),0)
It was nessesary to close the parenthesis of the second if

Resources