Count values from one column

dyheids

New Member
Joined
Apr 3, 2018
Messages
2
Can anyone help me count date from one column, duplicate values as one within a date. for example

Column 1 Column 2
3/1/18 eva
3/1/18 dan
3/2/18 eva
3/2/18 eva


If counted it should be 3 names only.
Thank you.....
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Here is one way:

Code:
Sub CountUniqueNameDateCombos()    Dim Rng As Range, R As Range
    Dim n As Long
    Dim SD As Object
    Dim KeyStr As String, RefStr As String

    Set SD = CreateObject("Scripting.dictionary")
    Set Rng = Range("A1", Range("A" & Rows.Count).End(xlUp))    'Assume data is columns A & B (Date & Name)

    RefStr = ""
    For Each R In Rng
        KeyStr = R.Value & " " & R.Offset(0, 1).Value  'Search Key stored in dictionary
        If Not SD.exists(KeyStr) Then    'Unique key value, not already in the dictionary
            SD.Add KeyStr, RefStr
        End If
    Next R


    MsgBox "There are " & SD.Count & " unique Date/Name combinations"


    'Put the unique values in column C. or Modify to put them where you like
    With Range("C1")
        For n = 0 To SD.Count - 1
            .Offset(n).Value = SD.keys()(n)
        Next n
    End With

    'Or else split the data and the name and put them in columns D & E. Modify to suit your requirements
    With Range("D1")
        For n = 0 To SD.Count - 1
            .Offset(n).Value = Split(SD.keys()(n), " ")(0)
            .Offset(n, 1).Value = Split(SD.keys()(n), " ")(1)
        Next n
    End With

    Set SD = Nothing
End Sub
 
Upvote 0
Yes it is possible. The specifics would depend on how you had the data organized on sheet 1 and sheet 2
 
Upvote 0

Forum statistics

Threads
1,215,004
Messages
6,122,659
Members
449,091
Latest member
peppernaut

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