Excel: Formula error when value is zero - excel

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)))

Related

EXCEL Averaging with multiple Criteria

I have tried 2 approaches to my problem and can't quite figure out where I'm going wrong.
=AVERAGEIFS(CALC!L:L,CALC!C:C,Consignee!A2,CALC!K:K,CALC!A:A) and =IF(AND(Consignee!A2=CALC!C:C,CALC!K:K=CALC!A:A),AVERAGE(CALC!L:L),0)
Basically I need to start with CONSIGNEE!A2, then find it's match in CALC!C:C, which I then need to check against CALC!A:A to find the ones that go with it in the same row and see if that/those cell(s) match any in CALC!K:K and then take the average of the corresponding values in CALC!L:L and average them. I hope that makes sense. I feel like I've gotten close but am missing something.
Thank you in advance for your help!
I suspect that the formula below may not be the most efficient possible but it will do the job.
=SUMPRODUCT((CALC!A:A=CALC!K:K)*(CALC!C:C=CONSIGNEE!A2),CALC!L:L)/SUMPRODUCT((CALC!A:A=CALC!K:K)*(CALC!C:C=CONSIGNEE!A2))
Edit
In my original answer a reference to L1 was erroneously left over from the formula I tested where I had L1 taking the place of CONSIGNEE!A2. I have corrected this error and believe that the formula works fine for your requirement now.
Note that there are two separate SUMPRODUCT functions which you can test each by itself, one returning the count, the other the sum. If the count = 0 a #DIV/0 error will occur. You can prevent that by embedding the formula in and IFERROR() function.

Excel - CountIfs (column A has target value, column B is blank)

First post, sorry if it's not according to site preferences. I searched around and couldn't find a post that was exactly like this, but sorry if this is a repeat as well.
I have the following code:
=COUNTIFS(A:A,"="&C3, B:B,"<>""")
For clarity, the code is supposed to identify instances where column A has a specific value (C3), and where column B is empty.
I'm familiar with Countifs, but it was the "if blank" portion that I've been really struggling with. On top of that, column B is populated with formulas, making this seemingly more challenging from my perspective as a couple methods I've tried only work if the cells are truly unpopulated. What I can say is that this formula is working with almost all of my examples, except 1, and I have no idea why this would be. For that matter I'm not entirely sure why this code works at all.
Any insight would be greatly appreciated.
Thank you very much.
To count if blank: "="
=COUNTIFS(A:A,"="&C3, B:B,"=")
Or if this is easier to understand:
=COUNTIFS(A:A,"="&C3, B:B,"=" & "")
Which is the same.
"=" in COUNTIFS does not match blanks that result from formulas. Dont ask me why!
As workaround, you can use the flexible and never vexing SUMPRODUCT:
=SUMPRODUCT((A:A=C3)*(LEN(B:B)=0))

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

Showing New and Old by Date using Excel

long time no chat, I am running into a situation in where a formula I wrote up seems not to be working correctly. I know it's probably me, but logic based programming seems to be the bane of my existence.
=IF(D1>2010,"New",IF(D1<2010,"Old",""))
Is the formula in question, now if I got this down correctly, which I thought I did, is that if D1 is greater than the year 2010 the cell would say New, and if it's less than 2010, it would say Old.
It's not working, for some reason I can't figure out why.
I have a similar formula that works:
=IF($B155<>"","Full",IF($J155<>"","Full","Empty"))
I figured the logic would be similar, it seems I'm wrong. Can someone help me solve this simple quandary, logic based math has never been my strong suit. Thanks.
If D1=2010, there's no true condition in IF clauses, and the result will be a blank cell ("").
=IF(D1>=2010,"New",IF(D1<2010,"Old","")) should do the trick.
If D1 is formatted as a Date, the following formula will give the desired result:
=IF(YEAR(D1)>=2010,"New",IF(YEAR(D1)<2010,"Old",""))

Having a div/0 error in excel 2007 return a 0 with in a large formula

I apologize if this is not considered real programming since it is in Excel but I need help and this is the most helpful place I know!
Alright so I have a very large if formula in excel:
=IF(AND(($EZ16+LF$1139)>$B$1145,($EZ16+LF$1139)<$B$1146),IF(OR(AND($FB16<LF$1141,$FB16>LF$1142),AND($FE16<LF$1141,$FE16>LF$1142),AND($FH16<LF$1141,$FH16>LF$1142),AND($FK16<LF$1141,$FK16>LF$1142),AND($FN16<LF$1141,$FN16>LF$1142),AND($FQ16<LF$1141,$FQ16>LF$1142),AND($FT16<LF$1141,$FT16>LF$1142),AND($FW16<LF$1141,$FW16>LF$1142),AND($FZ16<LF$1141,$FZ16>LF$1142),AND($GC16<LF$1141,$GC16>LF$1142),AND($GF16<LF$1141,$GF16>LF$1142)),FALSE,(EU16/EI16-1)),FALSE)
What can I do to it so that if it returns a div/0 error it will pass a value of 0 instead of the #DIV/0! error?
Would it be something like:
=IF(ISERROR(A1/B1),0,A1/B1)
If so how can I add that to my current formula and not break it? Would it be:
=IF(ISERROR(IF(AND(($EZ16+LF$1139)>$B$1145,($EZ16+LF$1139)<$B$1146),IF(OR(AND($FB16<LF$1141,$FB16>LF$1142),AND($FE16<LF$1141,$FE16>LF$1142),AND($FH16<LF$1141,$FH16>LF$1142),AND($FK16<LF$1141,$FK16>LF$1142),AND($FN16<LF$1141,$FN16>LF$1142),AND($FQ16<LF$1141,$FQ16>LF$1142),AND($FT16<LF$1141,$FT16>LF$1142),AND($FW16<LF$1141,$FW16>LF$1142),AND($FZ16<LF$1141,$FZ16>LF$1142),AND($GC16<LF$1141,$GC16>LF$1142),AND($GF16<LF$1141,$GF16>LF$1142)),FALSE,(EU16/EI16-1)),FALSE))**),0,IF**(AND(($EZ16+LF$1139)>$B$1145,($EZ16+LF$1139)<$B$1146),IF(OR(AND($FB16<LF$1141,$FB16>LF$1142),AND($FE16<LF$1141,$FE16>LF$1142),AND($FH16<LF$1141,$FH16>LF$1142),AND($FK16<LF$1141,$FK16>LF$1142),AND($FN16<LF$1141,$FN16>LF$1142),AND($FQ16<LF$1141,$FQ16>LF$1142),AND($FT16<LF$1141,$FT16>LF$1142),AND($FW16<LF$1141,$FW16>LF$1142),AND($FZ16<LF$1141,$FZ16>LF$1142),AND($GC16<LF$1141,$GC16>LF$1142),AND($GF16<LF$1141,$GF16>LF$1142)),FALSE,(EU16/EI16-1)),FALSE))
Thank you for the help!
EDIT:
Tim a tried your suggestion:
=IF(AND(($EZ16+LF$1139)>$B$1145,($EZ16+LF$1139)<$B$1146),IF(OR(AND($FB16<LF$1141,$FB16>LF$1142),AND($FE16<LF$1141,$FE16>LF$1142),AND($FH16<LF$1141,$FH16>LF$1142),AND($FK16<LF$1141,$FK16>LF$1142),AND($FN16<LF$1141,$FN16>LF$1142),AND($FQ16<LF$1141,$FQ16>LF$1142),AND($FT16<LF$1141,$FT16>LF$1142),AND($FW16<LF$1141,$FW16>LF$1142),AND($FZ16<LF$1141,$FZ16>LF$1142),AND($GC16<LF$1141,$GC16>LF$1142),AND($GF16<LF$1141,$GF16>LF$1142)),FALSE,IF(EI16=1,0,EU16/EI16-1)),FALSE)
Still getting a #DIV/0 error, any idea why?
Excel 2007 has a new IFERROR function that you can use like
=IFERROR(MyLongFormula,0)
=IsError(100/0) will return TRUE, so make the conditional before to output 0, =IF(IsError(*),0,...)
I wouldn't recommend duplicating the whole formula like that: a complicated formula just got twice as complicated.
Since the division only happens in one place, I'd recommend putting the check there. This:
...(EU16/EI16-1)...
becomes this:
...IF(EI16=1, 0, EU16/EI16-1)...

Resources