Count unique values with additional condition

BigDelGooner

Board Regular
Joined
Aug 17, 2009
Messages
197
I am really stuggling here guys so any help much appreciated. I need to count the amount of unique values in a range, but only count unique values that also have a seperate condition. To help illustrate with the 2 column dataset below....


Colour Letter
Yellow A
Yellow A
Green B
Yellow B
Blue A
Blue A
Yellow C

For this set of data i want 3 seperate cells for each 'Letter' telling me that, for 'A', the answer is 2 unique values (i.e. Yellow and Blue). For 'B' there is also 2 unique values (i.e. Green and Yellow) and finally for 'C' there is just 1 unique value (i.e. yellow).

Any help greatly appreciated. Many thanks
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
A UDF (User-defined function) would do:
This function:
Function Unq(Letr As String, letRng As Range, colorRng As Range) As Integer
Dim col As New Collection, i As Integer
On Error Resume Next
For i = 1 To letRng.Rows.Count
If letRng(i) = Letr Then
col.Add CStr(colorRng(i)), CStr(colorRng(i))
End If
Next
Unq = col.Count
End Function

could be used in the worksheet like =Unq("A",B2:B8,A2:A8)
 
Upvote 0

Forum statistics

Threads
1,216,777
Messages
6,132,663
Members
449,744
Latest member
kauamarcosms

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