Nested if formula (Excel) - 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

Related

Cell-Address with an IF Statement

I've been using =Cell("address",... to error check formulas I'm making to create a database and it's been working pretty well until I tried to scale up my index match formulas with some if statements.
I've narrowed the issue down to where I believe it's working as intended as long as the first statement in the if statement is true, yet if the calculation goes past that (even if the original formula is fine and returns a value) it will come back with #VALUE!.
EDIT: To be clear, the formula used above returns values without issue when not using the CELL-ADDRESS function involved. The formula also returns values when split up outside the IF-Statement.
I2=Valid
=CELL("address",IF($I$2="Valid",INDEX($I$2:$J$6,MATCH($U$1,$H$2:$H$6,0),MATCH($V$1,$I$1:$J$1,0)),IF($I$2="Invalid",INDEX($I$2:$J$6,MATCH($W$1,$H$2:$H$6,0),MATCH($V$1,$I$1:$J$1,0)),"Error")))
$I$2 is returned in the cell
I2=Invalid
=IF($I$2="Valid",INDEX($I$2:$J$6,MATCH($U$1,$H$2:$H$6,0),MATCH($V$1,$I$1:$J$1,0)),IF($I$2="Invalid",INDEX($I$2:$J$6,MATCH($W$1,$H$2:$H$6,0),MATCH($V$1,$I$1:$J$1,0)),"Error"))
#VALUE! is returned
Can anyone offer a fix for this or explain why it's happening and how to avoid it?
Any help would be appreciated.
Thanks!

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.

Need help fixing an IF(AND statement in 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),"-"))))

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.

Excel: Formula error when value is zero

I have used a formula to create a point system for my class. My formula is below, and it works great except that when C2 is zero, the score still shows "10" when I'd like it to be zero as well. I realize that this is an error in my formula but I can't seem to fix it without excel giving me an error message. Could anyone help me edit this formula to fix it?
(I'm a teacher and I'm just trying to make my life a little easier with excel.)
IF(TRIM(C2)="","",IF(C2<6.99,10,IF(AND(C2<=7.99,C2>=7),9,IF(AND(C2<=8.99,C2>=8),8,IF(AND(C2<=9.99,C2>=9),7,IF(AND(C2<=10.99,C2>=10),6,IF(AND(C2<=11.99,C2>=11),5,IF(AND(C2<=12.99,C2>=12),4,IF(AND(C2<=13.99,C2>=13),3,IF(AND(C2<=14.99,C2>=14),2,IF(AND(C2<=15.99,C2>=15),1,IF(AND(C2>=16,C2<=100),0))))))))))))
your first if statement says if c2 is nothing then its blank. why not make another one that check if its 0
This is untested but try
IF(TRIM(C2)="","",IF(TRIM(C2)=0,0,IF(AND(C2<6.99,10,IF(AND(C2<=7.99,C2>=7),9,IF(AND(C2<=8.99,C2>=8),8,IF(AND(C2<=9.99,C2>=9),7,IF(AND(C2<=10.99,C2>=10),6,IF(AND(C2<=11.99,C2>=11),5,IF(AND(C2<=12.99,C2>=12),4,IF(AND(C2<=13.99,C2>=13),3,IF(AND(C2<=14.99,C2>=14),2,IF(AND(C2<=15.99,C2>=15),1,IF(AND(C2>=16,C2<=100),0))))))))))))))
Again this is untested but hopefully you see what I am trying to do.
Perhaps:
=IF(C2="","",IF(C2=0,0,MAX(ROUNDUP(MIN(16-C2,10),0),0)))

Resources