C1 | C2 | C3 | C4 (expected result) |
---|---|---|---|
comp1 | sql 12 | test1 | 1 |
comp2 | sql 12 | test2 | 1 |
comp3 | sql 13 | test3 | 2 |
comp3 | sql 13 | test4 | 2 |
comp3 | sql 14 | test1 | 1 |
comp4 | sql 12 | test6 | 2 |
comp4 | sql 12 | test7 | 2 |
comp4 | sql 13 | test1 | 3 |
comp4 | sql 13 | test2 | 3 |
comp4 | sql 13 | test3 | 3 |
C1 | C2 | C3 | C4 (expected result) |
---|---|---|---|
comp1 | sql 12 | test1 | 1 |
comp2 | sql 12 | test2 | 1 |
comp3 | sql 13 | test3 | 2 |
comp3 | sql 13 | test4 | 2 |
comp3 | sql 14 | test1 | 1 |
comp4 | sql 12 | test6 | 2 |
comp4 | sql 12 | test7 | 2 |
comp4 | sql 13 | test1 | 3 |
comp4 | sql 13 | test2 | 3 |
comp4 | sql 13 | test3 | 3 |
I have a data similar to above. I need a macro to check how many values are in column C3 , corresponding to each combination of C1 and C2. Example, in row 1, for combination of comp1 and sql 12 --> we have only one value in column C3. Hence the result expected in C4 is 1. Row 3 and Row 4, we have 2 values responding comp3 and sql 13 combination. Hence the expected result in C4 is 2
Can someone please help to achieve this
Share Improve this question edited Feb 17 at 12:58 Dominique 17.5k19 gold badges78 silver badges144 bronze badges asked Feb 17 at 12:24 doubtingdoubting 71 silver badge7 bronze badges 1 |1 Answer
Reset to default 1As Darren suggest in the comments: Use the CountIfs
-function. The formula for your example would be =COUNTIFS($A$2:$A$11;A2;$B$2:$B$11;B2)
. It counts how often the value of A2 is in column A (A2:A11) and how often the value of B2 is in column B. Enter the formula into C2 and copy it down.
COUNTIFS
would achieve this. – Darren Bartrup-Cook Commented Feb 17 at 12:51