Counting Unique Values

Jar888

Board Regular
Joined
Jan 15, 2022
Messages
61
Office Version
  1. 2016
Platform
  1. Windows
I've got a bit of a question that I'm semi-stumped on. I have a list of dates in column A, with a list of names in column B. The names in column B are a variety of 30 or so names, but can repeat on certain dates. Is there a way to count the names in column B, only if column A is a unique date/value?
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hi
Try
VBA Code:
Sub test()
    Dim a, w
    Dim i
    a = Cells(2, 1).CurrentRegion
    With CreateObject("scripting.dictionary")
        For i = 1 To UBound(a)
            If Not .exists(a(i, 1) & a(i, 2)) Then
                .Add a(i, 1) & a(i, 2), Array(a(i, 2), 1)
            Else
                w = .Item(a(i, 1) & a(i, 2))
                w(1) = w(1) + 1
                .Item(a(i, 1) & a(i, 2)) = w
            End If
        Next
        Cells(2, 5).Resize(.Count, 2) = Application.Index(.items, 0, 0)
    End With
End Sub
 
Upvote 0
Another option using formulas.
This is an array formula and needs to entered with CTRL-SHIFT-ENTER.

Book1
ABCD
1DateNamesUnique
28/20/2023Name17
38/20/2023Name2
48/20/2023Name1
58/21/2023Name4
68/22/2023Name5
78/22/2023Name5
88/22/2023Name8
98/22/2023Name8
108/22/2023Name9
118/23/2023Name10
Sheet1
Cell Formulas
RangeFormula
D2D2=SUM(IF(FREQUENCY(IF($B$2:$B$11<>"",IF($A$2:$A$11&"\"&$B$2:$B$11=$A$2:$A$11&"\"&$B$2:$B$11,MATCH($B$2:$B$11,$B$2:$B$11,0))),ROW($B$2:$B$11)-ROW($B$2)+1),1))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0

Forum statistics

Threads
1,215,758
Messages
6,126,702
Members
449,331
Latest member
smckenzie2016

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