Count nonempty cells in column, if row contains word - excel

This is what I have now:
=COUNTA(FILTER(A14:O,SEARCH($A$4,A14:A),SEARCH("*",F14:F)))/2
Looks something like this
A B C D E F [...]
14 word1 a h X
15 word2 c k X
16 word3
17
18 word1 c
19 word2 a j X
20 word3 b X
[...]
What I want it to do:
Basically I want to know how many cells in column F aren't empty but only count those where the row contains word1 in column A
What it does:
If column F is empty it returns 0.5, when it's supposed to be 0
If column F has X in row 18 but not 14 it returns 1, as it's supposed to
If column F has X in row 14 but not 18 it returns 6, when it's supposed to be 1
If column F has X in both row 14 and 18 it returns 7, when it's supposed to be 2
If column F has X in any row but 14 it returns the amount of Xs, as it's supposed to
I feel like I'm making this sound more complicated than it actually is.

=COUNTIFS(A1:A7,"word1",F1:F7, "*")
SYNTAX : COUNTIFS

Assuming the list of words is in Column A and Column F contains whatever, you could use:
=SUMPRODUCT((A1:A7="word1")*(F1:F7>0))

You are picking up a lot of extra counts from columns B:E (some of which seem to be zero-length strings and look like empty cells, but still register).
Try
=COUNTA(FILTER({A14:A,F14:F},SEARCH($A$4,A14:A),SEARCH("*",F14:F)))/2

Related

Excel - sort 3 numbers MIN MAX and?

I have in Excel 3 columns with numbers, lets say x, y and z.
In a fourt column I want to have them sorted and as text concatunated.
Sample
Col A, Col B, Col C, Col D
12 , 34 , 26 , 122634 < result
54 , 87 , 54 , 545487
I did try using MIN and MAX, but of course how to get the one between.
Any sugestions?
Yes, you can use small (or large). The formula would be:
=SMALL(A2:C2,1)&SMALL(A2:C2,2)&SMALL(A2:C2,3)
where the 1st argument is the range of numbers and the 2nd argument is the "position" on the sorted range.

Count Excel cells in a row until the sum is reached?

I have two rows and want to count the number of cells in the row-2, offset by one column, I need to sum up to reach but not exceed the number in row-1
A B C D E F G
20 39
2 3 15 12 8 10
x y
So "x" should be 3 (2+3+15 < 20)
and "y" should be 4 (3+15+12+8 < 39)
I tried all sorts of formulas, but none worked, this one is supposed to work but doesnt:
=MATCH(A1,INDEX(SUBTOTAL(9,OFFSET(A2,,,,COLUMN(A2:G2))),0))
edit
The actual Excel had slightly different numbers
F D E F G H I J K L M N O P Q R
3404 1409 312971 290486 255425 233206 209780 852766 791217 762958 707437 705119 blank 23141
1135 470 104324 96829 85142 77735 69927 284255 263739 254319 235812 235040 blank 34212
Top row is 44 and the bottom one is 46
The formula I use is :
=MATCH(F44,INDEX(SUBTOTAL(9,OFFSET(F46,,,,COLUMN($F$46:$R$46))),0))
** Edit 2 **
Also - how can I exclude blank cells in this?

Can I use SUMPRODUCT to accomplish this?

Need to sum a range based on if a value is in a column and one of a set of values is in another column, or vice versa.
e.g. I have The following table:
A B C D
M C C 1
F C C 2
S N C 3
S N N 4
M - C 5
N C C 6
M C N 7
If (Column A contains "M" or "S") AND ((Column B contains "C" AND Column C Contains "C" Or "N" Or "-") OR (Column C contains "C" AND Column B Contains "C" Or "N" Or "-")) Then Sum column D
So from my table my results would be
1 + 3 + 5 + 7 = 16
You can use SUMPRODUCT like this:
=SUMPRODUCT(ISNUMBER(MATCH(A2:A10,{"M","S"},0)*MATCH(B2:B10&"^"&C2:C10,{"C^C","C^N","C^-","N^C","-^C"},0))+0,D2:D10)
MATCH is used to check for both valid possibilities in column A and then all 5 possibilities for concatenated columns B and C - if those conditions are met then column D will be summed. Extend column ranges as required but preferably don't use whole columns
.....or shorter with SUMIFS like this:
=SUM(SUMIFS(D:D,A:A,{"M";"S"},B:B,{"C","C","C","N","-"},C:C,{"C","N","-","C","C"}))
For that version you can use whole columns with no loss of efficiency.
Note that in this version all the separators in the array constants are commas EXCEPT for the semi-colon in {"M";"S"} which needs to be that way
I would add a fifth column with a condition for the current line returning the value in D if all conditions are true or 0 otherwise.
=Iif(AND(Or($A1 = "M", $A1 = "S"),OR(AND($B1 = "C",Or($C1 = "C",$C1 = "N",$C1 = "-")), AND($C1 = "C",OR($B1 = "C",$B1 = "N",$B1 = "-")))),$D1,0)
Then in a cell somewhere write =sum($E:$E). With your example, I get 16, as intended.

Excel Formula comparing two columns

Below is a sample of the data I have. I want to match the data in Column A and B. If column B is not matching column A, I want to add a row and copy the data from Column A to B. For example, "4" is missing in column B, so I want to add a space and add "4" to column B so it will match column A. I have a large set of data, so I am trying to find a different way instead of checking for duplicate values in the two columns and manually adding one row at a time. Thanks!
A B C D
3 3 Y B
4 5 G B
5 6 B G
6 8 P G
7 9 Y P
8 11 G Y
9 12 B Y
10
11
12
11
12
I would move col B,C,D to a separate columns, say E,F,G, then using index matches against col A and col B identify which records are missing.
For col C: =IFERROR(INDEX(F:F,Match(A1,E:E,0)),"N/A")
For col D: =IFERROR(INDEX(G:G,Match(A1,E:E,0)),"N/A")
Following this you can filter for C="N/A" to identify cases where a B value is missing for an A value, and manually edit. Since you want A & B to be matching here col B is unnecessary, final result w/ removing col B and C->B, D->C:
A B C
3 Y B
4 N/A N/A
5 G B
6 B G
7 N/A N/A
Hope this helps!

Excel: if any field in a row is not null, set the cell in the first column to an incrementing row number?

I'm trying to create a formula that will have the effect of automatically adding an incremental row number to the first column of my spreadsheet when any data is entered in any column of the row.
So for example, if my table looks like this:
a b c d e f
1 # x x x x x
2 # x x x x x
3 # x x
4 # x
5 # x
I would like the 'a' column to read:
0
1
2
3
4
And if I added more data in any column, e.g.:
a b c d e f
1 # x x x x x
2 # x x x x x
3 # x x x
4 # x x
5 # x x
6 # x
7 # x
It would then automatically up the index row 'a' to read as:
0
1
2
3
4
5
6
I hope this makes sense! Any help, or even just a tutorial to point me in the right direction would be so appreciated!
Here is the answer:
=if(counta(B2:F2)>0,A1+1,"")
The above works! Thanks to Alan Whitelaw for the answer, only posting this for others as it has the fixed syntax.
If I undersand corectly, and the sheet will always be filled in "in order" down the rows this should work
=if(counta(B2:D2)>0,A1+1,"")
Pop this in A2, and where B2:D2 is the rest of the row to test.
Excel's counta() counts non-blank cells.

Resources