Excel 2010 If Cell = N/A then value from another cell, if not N/A then value from a different cell - excel-formula

I need a formula in cell D1 to read
if cell A1 = N/A and B1 = 0 or < 1
then use value from B1
if not N/A and <> 0 or > 1
then use value from C1
Any suggestions?
I would like to add another condition to =IF(AND(B2<>"N/A",OR(C2<1,C2=0)),I2,C2).
I need to add another OR clause stating B2<>"N/A" and C2>0, then L2 has to be 0. Is this possible?

I think this is pretty close to what you want in cell D1 but your conditions for choosing C1 are not clear.
=IF(AND(A1 <> "N/A", OR(B1 = 1, B1 =0)),B1,C1)
N/A would need to be the text "N/A" for this to work
If N/A is the Excel error Type #N/A then you should use
=IF(AND(Error.Type(A1) <> 7, OR(B1 = 1, B1 =0)),B1,C1)
as suggested by chuff in the comments

Related

How to test cases with intervals in Excel

I have a spreadsheet with the value in A1 = 94. I would like to put in B1 a calculation such as:
if A1 is within [85;90], then B1 = A
else if A1 is within [90;95], then B1 = B
else if A1 is within [95;100], then B1 = C
is there a way to do it quickly without VBA please?
You need nested IFs
Paste this formula in B1:
=IF(A1>=85, IF(A1>=90, IF(A1>=95, IF(A1>100, "Too High", "C"), "B"), "A"), "Too Low")
If A1 = 85, 90 or 95 it will round up a category not down - to change that replace >= with > in the formula

How to count until a certain value?

I am just using formulas in excel and was wondering how you could count all the 0s until a 1 is reached, and then start the process over again. Would this be possible with just formulas?
Right now I am trying to use,
=COUNTIF(INDIRECT(F2:F28,0)),1)
... but it does not seem to work.
Data:
0
1
0
1
1
0
0
0
0
0
0
1
0
1
0
What you're describing here is known as a (Do) While loop in VBA.
Admittedly, something VBA is much better equipped to handle than a formula - literally needs few lines of code. Should be something you should consider looking into
You can technically fake a Do While with a formula. But this is
generally a practice I would not exactly recommend.
Under presumption you data input starts in Cell F2 then formula in adjacent Column G2
=IF(F2=0, SUM(G1, 1), 0) and drag the formula accross. Produces the expected result
In B2 enter:
=IF(OR(A2=0,A1=1),"",COUNTIF($A$1:A1,0)-SUM($B$1:B1))
and copy downward:
This seems to work according to your sample data,
=COUNTIF(F2:INDEX(F:F, IFERROR(AGGREGATE(14, 7, ROW($1:2)/(F$1:F2=1), 1), ROW(F2))), 0)
I have a solution, but it's not very elegant. Maybe someone else can improve on it. But here it is:
Assuming your data is in column A.
1) In B1 enter a 1 if A1 is a 0 or 0 if A1 is a 1.
2) In B2 enter the formula =IF(A2=0,B1+1,0)
3) Drag the above formula all the way down
4) In C1 enter the formula =IF(B1>B2,B1,"")
5) Drag the above formula all the way down
6) Column C should now have all of the counts of zeroes.
You can use the following formula in column B:
=IF(A3=1,COUNTIF(A$1:A2,0)-SUM(B$1:B1),"")
starting in row 2 and drag it down.
Put 1 in the cell next to the first 0 (In my example that's in A1, so i've put 1 in B1);
Then try this =IF(A2=A1;B1+1;1)

How to change the value of a cell wiout changing the range?

I have the following columns and data:
column1
1(cell A1)
2(A2)
3(A3)
Say I want to do like transpose(A1:A3) but want to change the value of 2 in A2 to 0, "inside the transpose formula". Is this possible??? Thank you very much.
{ =TRANSPOSE(A1:A3*(ROW(A1:A3)<>2)) }
Some explanation:
We are transposing an array, not directly A1:A3 but the result of one-by-one multiplication of A1:A3 and (ROW(A1:A3)<>2)). This results in the column vector:
A1 * 1 A1
A2 * 0 = 0
A3 * 1 A3
Which is what you want to transpose.

IF formula returning 0 or 1 depending on values in 3 cells?

I'm a beginner in Excel and I've been trying to make an IF formula that will return 0 or 1 if certain conditions are met.
The formula in A3 must look at
A1 to see if A1=1111
A2 to see if A2=21,00
A2 to see if A2=24,00.
So, if A1=1111 and A2=21,00 or 24,00 the result in A3 must be 1, but if A1=1111 and A2 is any other value, A3 must be 0. LE: If in other rows the value is 1112 the formula should return 1.
Yes, use and as well as or -
=IF(AND(A1=1111,OR(A2=21,A2=24))=TRUE,1,0)
Per comments, to add more arguments, just expand the first test for the and with an or -
=IF(AND(OR(B3=1111,B3=1112,B3=1113,B3=5555),OR(C3=21,C3=22.4))=TRUE,1,0)
update
=IF(B3<>1111,1,IF(AND(B3=1111,OR(C3=21,C3=22.4))=TRUE,1,0))

Logical calculation in Excel

I need advice/help. I am working on calculation in excel where I have data like mentioned below.
. A B C D E F G H
1| A275 A277 A273 A777 A777 TOTAL A222 GRAND TOTAL
2| 5 7 4 3 4 7 7
Now, I want to count row 2 based on the header.
Here is the condition.
If A1 <> B1 then take A1, if B1 <> C1 then take B1, if C1 <> D1 then C1, so on.
But tricky part is...
If D1<>E1 then D1 else (if E1<>F1 then E1 else (if F1 = "TOTAL" then F1 else(if F1<>G1 then F1)))
In short H2 should have 30 and not 37.
Added comments:------------------------------------
So, Basically if A1<>B1 then take A1 but if A1=B1 then take B1, but then for B1, its a same rule like if B1<>C1 then take B1, but if B1=C1 then take C1 and for C1, same rule. Stopping point will be "TOTAL". Along with these logic I need to check if any cell in row 1 is "TOTAL" then take value for same column. Now this "TOTAL" can be in any cell in row 1.
So from above table my calculation will be 5(A2) + 7(B2) + 4(C2) + 7(F2) + 7(G2) = 30
In this calculation I have not included D2 and E2 as D2=E2 so I took D2, here E2<>F2 so I should have taken E2, but as F2="TOTAL" so I took F2 and not D2 and E2.
I hope this make sense. (Sorry, I know its confusing.)
I have data in more then 100 columns.
Can this be achieved using Macro?
------------------------------------------------------------
Another pain point is data and header are dynamic, so I can't have a fix format. Logic should be in a way that can handle the dynamic data and header.
Any help or suggestion will be greatly appreciated.
I achieved the results you want with this.
Add a helper row. In cell A3 write this formula and drag it to the right:
=IF(OR(A$1=B$1,B$1="TOTAL"),0,1)
Calculate sum in say cell H4 (not H2 because if the formula refers to entire row 2 there will be circular reference):
=SUMIF($3:$3,1,$2:$2)

Resources