Count Duplicate Rows with Conditions

wolf11

New Member
Joined
Jul 9, 2012
Messages
2
Hi, Anyone who can help me with a formula for counting unique rows with condition

1) it must count only the unique task number
2) the counted unique task number must have task type P
result: 3


( optional ) Count Unique Task Number must have Task Type P with Name D
result: 1


I know the formula to compute for unique text only in one row but what bout with conditions?
Would really appreciate help :)

=SUMPRODUCT((B3:B12<>"")/COUNTIF(B3:B12,B3:B12&""))


A1BCD
2Task NumberTask TypeName
3T1CM
4T2PD
5T2PD
6T3CM
7T4CL
8T5CM
9T6PR
10T6PR
11T7PR
12T8CL

<tbody>
</tbody>

<tbody>
</tbody>
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Excel 2010
ABCDE
1Task NumberTask TypeName
2T1CM31
3T2PD
4T2PD
5T3CM
6T4CL
7T5CM
8T6PR
9T6PR
10T7PR
11T8CL
Sheet2
Cell Formulas
RangeFormula
D2{=SUM(IF(FREQUENCY(IF(B2:B11="P",MATCH("~"&A2:A11,A2:A11&"",0)),ROW(A2:A11)-ROW(A2)+1),1))}
E2{=SUM(IF(FREQUENCY(IF(B2:B11="P",IF($C$2:$C$11="D",MATCH("~"&A2:A11,A2:A11&"",0))),ROW(A2:A11)-ROW(A2)+1),1))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Hi, Anyone who can help me with a formula for counting unique rows with condition

1) it must count only the unique task number
2) the counted unique task number must have task type P
result: 3


( optional ) Count Unique Task Number must have Task Type P with Name D
result: 1


I know the formula to compute for unique text only in one row but what bout with conditions?
Would really appreciate help :)

=SUMPRODUCT((B3:B12<>"")/COUNTIF(B3:B12,B3:B12&""))



A1
B
C
D
2
Task Number
Task Type
Name
3
T1
C
M
4
T2
P
D
5
T2
P
D
6
T3
C
M
7
T4
C
L
8
T5
C
M
9
T6
P
R
10
T6
P
R
11
T7
P
R
12
T8
C
L

<tbody>
</tbody>

<tbody>
</tbody>

Control+shift+enter, not just enter...

1)
Rich (BB code):
=SUM(IF(FREQUENCY(IF(B3:B12<>"",MATCH("~"&B3:B12,B3:B12&"",0)),
  ROW(B3:B12)-ROW(B3)+1),1))
2)
Rich (BB code):
=SUM(IF(FREQUENCY(IF(B3:B12<>"",IF(C3:C12="P",
  MATCH("~"&B3:B12,B3:B12&"",0))),ROW(B3:B12)-ROW(B3)+1),1))
3)
Rich (BB code):
=SUM(IF(FREQUENCY(IF(B3:B12<>"",IF(C3:C12="P",IF(D3:D12="D",
  MATCH("~"&B3:B12,B3:B12&"",0)))),ROW(B3:B12)-ROW(B3)+1),1))

if there are no special meaning chars around the entries in column B, you might want to remove the "~"& and &"" bits from the formulas.
 
Upvote 0
Hi,
You can use the following code:
Code:
Sub Counting()
Dim i&, NoDupes As New Collection

On Error Resume Next
For i = 3 To 12
  If Cells(i, 3).Value = "P" Then 'And Cells(i, 4).Value = "D"
    NoDupes.Add 1, Cells(i, 2).Value
  End If
Next i

MsgBox NoDupes.Count
End Sub
Best regards.
 
Upvote 0

Forum statistics

Threads
1,216,146
Messages
6,129,125
Members
449,488
Latest member
qh017

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top