How to test cases with intervals in Excel - 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

Related

Multiply a number by previous cell and different column

I wish to know if it is possible to multiply column(A) by column(B) and then keep on multiplying the last column(A) result by column(B), in a fast way instead of doing it manually that is.
For example:
A1 = 200
B2 = 0.8
C1 = A1 * B2 = 160 OR C1 = 200 * 0.8
C2 = C1 * B2 = 128
C3 = C2 * B2 = 102.4
C4 = C3 * B2 = 81.92
Etc...
You can use:
=SCAN(200,SEQUENCE(4),LAMBDA(a,b,a*0.8))
Note that you can use references for both 200 and 0.8.
You can use exponents to make the dynamic formula you describe based on the row. So if you put this in cell A2 and it would do what you describe, and then just drag down:
=$A$1*($B$2)^row()
Example on google Sheets (same formula works on Excel).

Sum only cells with prefix letter in a row

I have data in Row 1 as follow:
A1 = 8
A2 = 9
A3 = CN2.75
A4 = CN3
I would like the result in cell B2 = sum range A1 to A4 and only sum cells with prefix letter "CN". The sum result in cell B2 should be = 2.75 + 3 = 5.75
=SUMPRODUCT(+IF(LEFT(A1:A4,2)="CN",1,0),IFERROR(VALUE(RIGHT(A1:A4,LEN(A1:A4)-2)),0))
Prefer even JvDV's Version from the comments, even more efficient
Enter as an array formula Ctrl+Shift+Enter

Add A1 to C1 if B1 = Specific Number

I will try to be as clear and concise as possible. I am working on a spreadsheet in which I have item prices listed in a range of A1:A40. B1:B40 lists a numerical digit (either 1, 2, 3, etc.) that corresponds with a purchase category type (groceries, gas, etc.). Now I want one cell, such as C1, to add all instances in the A range that equal a specific number in B.
For example:
A1 = $5.00 | B1 = 1 | C1 = The sum in range A1:A3 if it's corresponding B value is equal to 1 (In this case B1 and B3, so C1=A1+A3)
A2 = $2.50 | B2 = 2 | C2 = The sum in range A1:A3 if it's corresponding B value is equal to 2 (In this case B2, so C2= B2)
A3 = $4.00 | B3 = 1 | C3 =
Use SUMIF Function
SUMIF(range, criteria, [sum_range])
In Cell C1 enter the formula = SUMIF(B:B,1,A:A)

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)

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

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

Resources