Simplify a calc/excel formula with If / And - excel-formula

How could I make that simplier:
IF(AND(C$36>140;D$36>140;E$36>140);"OK";IF(AND(D$36>140;E$36>140;F$36>140);"OK";IF(AND(E$36>140;F$36>140;G$36>140);"OK";IF(AND(F$36>140;G$36>140;H$36>140);"OK";"NO"))))
This formula is in I38.
The idea is to check if in the 6 cells before (on line 36), 3 in-a-row are above 140. So the cells from C36 to H36.
I'm wondering if that is possible to make that simplier/prettier. And also so that ii is to replicate it.

The formula can be shortened with COUNTIF. Also, separate formulas make it easier to read.
Enter =COUNTIF(C36:E36;">140") in cell E37 and then drag right to fill through H37.
Set I38 to =IF(COUNTIF(E37:H37;"=3");"OK";"NO").
EDIT:
The first formula checks each set of 3 cells in a row to see how many numbers in the set are over 140. The second formula checks if any of the results are equal to 3. If so, then there is at least one set where 3 out of 3 are over 140.
Combining this into one formula would look like this:
=IF(OR(COUNTIF(C36:E36;">140")=3;COUNTIF(D36:F36;">140")=3;COUNTIF(E36:G36;">140")=3;COUNTIF(F36:H36;">140")=3);"OK";"NO")
Or this:
=IF(MAX(COUNTIF(C36:E36;">140");COUNTIF(D36:F36;">140");COUNTIF(E36:G36;">140");COUNTIF(F36:H36;">140"))=3;"OK";"NO")

I like your idea for making this formula, however you can improve it a bit, by using a combination of OR and MIN functions.
Try This:
=IF(OR(MIN($C$1:$E$1)>140,MIN($D$1:$F$1)>140,MIN($E$1:$G$1)>140,MIN($F$1:$H$1)>140),"ok","No")

Related

Excel formula: how to get sum of calculated values?

I have following data in Excel:
A B C
1 Task Name Total Effort (days) %Finished
2 Task 1 5 30
3 Task 2 8 25
4 Task 3 23 18
5 Task 4 32 5
All I want to get is "=SUM(B2*C2 : B5*C5)". But Excel doesn't allow me to do this. How do I achieve my goal?
This is simple with SUMPRODUCT:
=SUMPRODUCT(B2:B5,C2:C5)
To elaborate, while #Olly's answer SUMPRODUCT(B2:B5, C2:C5) is indeed correct, however I got impression from your original post that you are a bit confused about the selectors in hand - I do believe you should study up on it before even copy-pasting any formula.
In excel formulas, if you are refering to a range of cells, you do it by declaring the range from it's starting point, to it's ending point with a colon.
So for example, the green range would be A1:A5, the blue range would be C3:E3 and the yellow range would be F5:G11
Next we have separators, these seperate individual ranges (or cells - even an individual cell is a range itself, a range with a size of 1 cell)
For example with the following range, we would select it as (A1:A2, A5, A7:A8) notice the comma (,) acting as a separator.
Now as to how =SUMPRODUCT actually works, it takes two ranges, pits them side by side. It then does multiply the first cell of the first range with the first cell of the second range and so on. In the end, it adds them all together.
That sounds a bit difficult in words. Here is an illustration
So yes, this actually means the individual values don't even have to be side by side.
Hopefully you understand now not only how your code should look like, but also why your original code didn't work! :)

Can't get right autofill on specific case number

I have a column with specific case numbers, which look like 1/2017, 2/2017, etc. The series can go until infinite (I don't know for sure how many cases I will have), but it would be nice to be able to use autofill. If I select the first 3 values and drag down the fill handle, I get 1/2018, 2/2018, 3/2018. I would need exactly the opposite, to linearly change the first number and leave 2017 alone. The formatting of the column is General. Should I create a custom formatting and/or block the changing of the 2017 somehow? (I know that you can block a value of a cell from changing with the $ operator)
Thanks.
Put 1 in a cell and 2 in an adjacent cell. Use a custom number format of 0/\2\0\1\7 (which excel will auto-repair to 0/2\017). Fill as necessary.
Remember that you are now looking for 1, 2, etc in VLOOKUP's or any other cell comparison or matching.

Excel: How do I sum cell values every nth colum

I have the following table:
and I'd like to have the total for each player but values are every 3 columns.
As you can see from the picture on the bottom part I wrote what manually I should enter.
For player 1
=SUM(D3;G3;J3...)
Player 2
=SUM(D4;G4;J4...)
and so on. What formula should I use to calculate automatically every 3 columns? I know how the MOD works but on the net I found too many examples each one using different methods and none worked so far. Can anyone help me please or point me to the right direction to understand how it works to get this data since I'll be using this a lot (get value from cell every nth column).
thanks
It looks like you should just be using SUMIFS here:
=SUMIFS(3:3,$2:$2,"TOT")
This will sum every value on row 3 (Player 1) where the value in row 2 is "TOT" (every 3rd column). Put this in cell B18 and just copy down in your column B.
Or, in case you change your column labels, you can refer to cell D2 instead of typing "TOT" in the formula:
=SUMIFS(3:3,$2:$2,$D$2)
Try this, it will total all the cells that occur every 3 columns beginning at column D. Z3 can be increased to any column you require:
=SUMPRODUCT((D3:Z3)*(MOD(COLUMN(D3:Z3)-1,3)=0))
The explanation on how it works can be found here (I advise you to bookmark this site for future references. They have many other helpful formulas and functions).
Applying this formula to your reality should be something like this for Player 1 (Not tested. Adjust the ranges as required):
=SUMPRODUCT(--(MOD(COLUMN(D3:Z3)-COLUMN(D3)+1,3)=0),D3:Z3)

Excel: Get values in non-adjacent cells based on multiple criteria

I have an excel sheet sort of like this:
I'm trying to figure out how to get the totals in cells B1 through B4.
I tried INDEX-MATCH, where I tried to match the words in A1:A4 with the words in row 7, get the numbers relative to them, and then sum them, but it was a lot of Google searching and stabbing in the dark -- every attempt returned an error.
I also tried to INDEX-MATCH the words in A1:A4 with row 7, and then nest a VLOOKUP in there where it'd get the number relative to "visits:" but that didn't work at all either.
Is INDEX-MATCH even the correct function? Any help would be much appreciated, I'm not even sure what to Google anymore.
EDIT: I need to use a search function of some kind, like the INDEX-MATCH method, rather that static formulas because the sheet will change periodically and I don't want to have to update the formula every time I add an animal.
Your data table is unusual in structure.
However, if you are gong to keep a fixed rule such that the number of visits is always offset 2 rows and 1 column from the animal type(and that itself is always in row 7), you could do:
In B1:
=SUM(IF($A$7:$AAA$7=$A1, $B$9:$AAB$9, 0))
Confirm with Ctrl-Shift-Enter, and then copy down..
DOes this work?
=SUM(IF($B$7=A1,$C$9,0),IF($D$7=A1,$E$9,0),IF($F$7=A1,$G$9,0),IF($H$7=A1,$I$9,0))
I'm not sureto have fully grasped your challenge. Yet it seems the following solution would work:
Add the following formula in each box where the number of visits is added as
=+SUMIF($A$1:$A$end;animal;$B$1:$B$end)
Where end is a number of the last cell in the first and second columns data contain the data.
And animal is the cell that contains the name of the animal.
Therefore in your simple example, the formulas on cells C9;E9;G9 and I9 would be respectively:
=+SUMIF($A$1:$A$4;B7;$B$1:$B$4) ; =+SUMIF($A$1:$A$4;D7;$B$1:$B$4); =+SUMIF($A$1:$A$4;F7;$B$1:$B$4) and =+SUMIF($A$1:$A$4;H7;$B$1:$B$4).

Excel spreadsheet: how to find the difference between two sets of columns in the same row

Not sure this is even possible, but perhaps someone knows how to do it. I have a row with 6 columns (A-F). The first three columns are one set and the last three columns are a different set. I want to sum both sets and then find the difference between the sums. For example if the row is:
A1 A2 A3 A4 A5 A6
4 5 6 7 8 9
I want to add 4+5+6 and 7+8+9 and then find the difference between the two sums.
I think its something like this: =SUM(A1:A3)-SUM(A4:A6).
If you are only interested in the magnitude, you can put it in an absolute value: =ABS(SUM(A1:A3)-SUM(A4:A6)).
[edited to match revised post]
Also, now that I read your post more carefully, you also mention you want to add items within columns as well. In that case, its the same formula, except you change the letters, not the numbers: =SUM(A1:C1)-SUM(D1:F1).
In the spirit of the previous answer, it's
=SUM($A$1:$A$3)-SUM($A$4:$A$6)
Another solution is:
=$A$1+$A$2+$A$3-$A$4-$A$5-$A$6
The dollars aren't necessary, but if you build this formula using the mouse, you will get them and they don't matter.

Resources