if i put number 1 in cell C6 then -35 or if i put 2 in cell C6 then +35 - excel-formula

I'm trying to add and minus the number from Cell E9 to display in Cell E8 e.g if i type number 1 in cell C6 then -35 or if i type number 2 in Cell C6 then +35 to the cell E9 to display in cell E8. Here is my formula below it works with number 1 but not with number 2.
=E9-IF(C6=1,35,IF(C6=2,+35))
Why does the formula don't work?

This should do the trick:
=E9-IF(C6=1,35,IF(C6=2,-35))
The issue is that your take - IF, so no matter what, both of your previous values would have get you a minus sign (- x + = -). (35 & +35 is the same)
There is a really good funcion in Excel "Evaluate Formula", that has step-to-step progress how the formula evaluate the calculation progress.
In our case you will see that the original formula would have progressed like this:
Original excel formula (typed 2 in C6):
0-IF(C6=1,35,IF(C6=2,35))
Next step, since cell C6 is 2, the first part of IF returns FALSE.
0-IF(FALSE,#N/A,IF(2=2,35))
Start evaluating next part (false part of IF, where 2=2 will be true)
0-IF(FALSE,#N/A,IF(TRUE,35))
The last part will give 35, but since you have minus:
0-IF(FALSE,#N/A,35)
You actually is arriving at the same number as the previous statement in the IF formula.
0-35
However,
if you set -35 in the last part IF(C6=2,-35) your final step will look like this:
0--35 -> 0+35

Related

Is it possible to have IF formula delete a row?

I have a formula that right now pulls and outputs on another sheet whether the B1 Cell is equal to “YES” then print A1 in the new sheets Cell I have the formula entered in, if it is not then it leaves the cell blank and this goes on for as many cells as needed.
Here is my formula
=IF((Sheet1!B1)=“YES”,Sheet!1A1,””)
I am wondering if there is a way to change the formula to where if it is not equal to “YES” then instead of leaving the Cell blank it deletes the entire row instead.
I know the final ,””) part of the formula is what I used to state the Cell will be blank. I’m just unaware if there is a function or anything I can input instead to state if not “YES” then delete the Row.
Example of what is happening:
If I have these entries in Sheet 1
A
B
1
85
YES
2
47
NO
3
74
YES
The output on Sheet 2 using my formula will be:
A
B
1
85
2
3
74
I am looking for it to look like this:
A
B
1
85
2
74
3
Thanks!

Formula to add a number to the cell and change that value if it is greater than certain number

In Column A I have numbers from 1 to 30 and in Column B I want to add 10 to the number in column A i.e.
if A1 is 1 I want 11 in B1 and in C1 I want 21 and
if A2 is 2 I want 12 in B2 and in C2 I want 22.
I don't want the numbers in columns B and C to exceed the maximum limit of numbers I have in Column A, in this case that is 30.
I need a formula to achieve this so that none of the cells in column B and C has the number exceeding 30 and if the addition exceeds that I want 30 to be subtracted from it. I tried this with IF but it didn't help as I don't know how to manipulate the current cell after adding the number.
Screenshot of expected results:
I want the number in B Column to be addition of 10 to the number in A Column and it should not exceed maximum number.
Maybe, in B1:
=A1+10-30*(A1+10>30)
and in C1, both copied down to suit:
=B1+10-30*(B1+10>30)
Considering B1, the above can be simplified slightly by rendering (A1+10>30) down to (A1>20).
A1+10 is the basic requirement.
The condition is that where A1+10 exceeds 30, a deduction of 30 should be applied. This can be restated as "where A1 exceeds 20".
(A1>20) returns either TRUE (when A1 is more than 20) and FALSE (otherwise).
What may not have been appreciated by all is that when used as a multiplier, Excel treats TRUE as 1 and FALSE as 0.
So when A1 is less than or equal to 20, nothing is deducted from to A1+10. 30*(A1>20) becomes 30*FALSE (effectively 30*0), which is 0. However, when A1 is more than 20 30*(A1>20) becomes 30*TRUE (effectively 30*1), which is 30.
The formula for B1 is:
=IF(A1+10>MAX($A$1:$A$30),A1+10-MAX($A$1:$A$30),A1+10)
(For C1 just do "Fill Right" from B1.)
Sometimes it's better to use several columns to get to the result:
First I created in D1 =A1+10, then in E1 =MAX($A$1:$A$30).
The $ means that the column or row number does not change when you fill down, so A1 stays fixed to A1 in every cell.
In F1 I created an IF formula: =IF(D1>$E$1,D1-$E$1,D1) which means "IF D1 exceeds the highest value in A1 to A30 THEN subtract that highest value from D1 ELSE just display D1 (=A1+10)"
And if you substitute these values:
(E1): =IF(D1>MAX($A$1:$A$30),D1-MAX($A$1:$A$30),D1)
(D1): =IF(A1+10>MAX($A$1:$A$30),A1+10-MAX($A$1:$A$30),A1+10)
you get the result I mentioned in the first place.

excel exclude a certain value from mode average

I'm looking for a formula that can find the Mode Average from a range of cells but exclude the value 14 from the range
example
A1 =26
A2 =14
A3 =14
A4 =14
A5 =26
A6 =3
A7 =16
A8 =16
A9 =26
Result would be:26 and not 14
Array formulas to the rescue:
=MODE(IF(A1:A6 <> 14,A1:A6))
Enter it via Ctrl + Shft + Enter
Not very elegant, but it works:
=(SUM(C3:C11)-COUNTIF(C3:C11,14)*14)/(COUNT(C3:C11)-COUNTIF(C3:C11,14))
c3:c11 is the range I am looking at on my test sheet.
I am basically looking for the sum of all values in the considered range, subtract 14 times the occurence of the number 14 from this sum and then divide the result by the total number of cells minus the occurences of 14 again. The whole thing will look much nicer, if you have the luxury of another cell that could serve as the "14-counter".
Edit: I overlooked the word "mode" in the question. This answer will only compute the average ...

How do I link the content of a cell to another worksheet as opposed to the value?

I realize my title doesn't really explain what I'm asking as I don't know the correct terminology but bear with me and I'll explain my question.
I know how to link two cells so that if one changes, the other does as well (i.e. cell C3 is linked to cell E5 by selecting cell C3 and entering "=E5"). But how do I link the information in the cell to another cell?
If my worksheet looks like this:
cell B1 - Grapes, cell C1 - 50
cell B2 - Apples, cell C2 - 60
and I link cell F1 to cell C2 with "=C2". If I change the order of cell B1 and cell B2 to become alphabetical then cell F1 is no longer linked to the value in cell C2 (50) but changes to the value that now becomes cell C2 (60). How do I link cell F1 to the actual value (50) in cell C2 even if the order changes.
Help... Thank you!
Not sure if this is an efficient method; if i correctly understood your question then you can use = to link two cells For example:
Sheet one can look like this
A B C D E
1 1 2 3 4 5
2 5 4 3 2 1
3 1 2 3 4 5
Total 7 8 9 10 11
Sheet two requires cell links so you do:
TotalForA =Sheet1!A4 //output will be 7
TotalForB =Sheet1!B4 //output will be 8
.
.
.
In a simple word you can use = sign and click on whatever cell you're like to get.

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