• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Finding Distinct Names and Counting associated numbers with them

fahadferoz

Member
Hi

Please have a look at the following spreadsheet for details. The requirements are mentioned there as well.

Thank you for your help!
 

Attachments

  • Name and Number Count.xlsx
    784.6 KB · Views: 11
I am sorry but I have not used advanced filter. Could you please apply it in attached spreadsheet.

Thanks for your understanding!
 
May be this to try with macro

Code:
Sub UniqueValues()
Dim ws As Worksheet
Dim uniqueRng As Range
Dim myCol As Long

myCol = 2
Set ws = ThisWorkbook.Worksheets("Sheet1")

Set uniqueRng = GetUniqueValues(ws, myCol)

End Sub


Function GetUniqueValues(ws As Worksheet, col As Long) As Range
Dim firstRow As Long

With ws
    .Columns(col).RemoveDuplicates Columns:=Array(1), Header:=xlNo

    firstRow = 1
    If IsEmpty(.Cells(1, col)) Then firstRow = .Cells(1, col).End(xlDown).Row

    Set GetUniqueValues = Range(.Cells(firstRow, col), .Cells(.Rows.Count, col).End(xlUp))
End With

End Function
 
hii,

please find the attached solution using pivot tabel .it is very easy and fast with out using long formula

thanks
rahul shewale
 

Attachments

  • Book1..pivot table...n.xlsm
    387.4 KB · Views: 4
May be this to try with macro

Code:
Sub UniqueValues()
Dim ws As Worksheet
Dim uniqueRng As Range
Dim myCol As Long

myCol = 2
Set ws = ThisWorkbook.Worksheets("Sheet1")

Set uniqueRng = GetUniqueValues(ws, myCol)

End Sub


Function GetUniqueValues(ws As Worksheet, col As Long) As Range
Dim firstRow As Long

With ws
    .Columns(col).RemoveDuplicates Columns:=Array(1), Header:=xlNo

    firstRow = 1
    If IsEmpty(.Cells(1, col)) Then firstRow = .Cells(1, col).End(xlDown).Row

    Set GetUniqueValues = Range(.Cells(firstRow, col), .Cells(.Rows.Count, col).End(xlUp))
End With

End Function
No Monty, it does not work. I tried it in Macro. It does not do it. You can try it yourself.
 
Back
Top