Counting Rows with Duplicate Values

In column A I have last name,  and there are multiple rows that contain the same Last name.

I want the count of last names, but only one to count one occurance of the same name.

How would I do this.  I have Excel 2003.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You could do this via pivot table.
seamus9909Author Commented:
No that counts each occurance of the last name.

Paste anywhere and drag it down
Try that - it will display how many times a same name occurs in column A
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

seamus9909Author Commented:
Ok I am not explaining this correctly.

I want to only count the occurance of the last name once.  So:


Count of Dean = 1
Count of Smith = 1
I would also check out the match function.  It sounds like it would do what you need.

Hmmm perhaps you are trying to get a list/count of unique last names?  Because the count will always equal one based on your recent post.
seamus9909Author Commented:
Yes I want to get a list of all the names found.
Ok.... use advanced filter.

1)Select column containing last names
2) hold alt and press dfa
3)Click the checkbox for unique records only
4)Look in bottom left hand corner of the Excel window.  You should some something like 9 of 13 records found.

You should see a list of all unique last names, and the number (9) would tell you how many unique last names exist.

Martin LissOlder than dirtCommented:
Display the unique names in column B in a button or macro

Dim colNames As New Collection
Dim RowCount As Long
Dim i As Long

RowCount = ActiveSheet.Range("A:A").End(xlDown).Row - 1

On Error Resume Next
For i = 1 To RowCount
    colNames.Add Range("A" & i).Value, Range("A" & i).Value

For i = 1 To colNames.Count
    Range("B" & i).Value = colNames(i)
You are saying the same thing here

"No that counts each occurance of the last name."

"I want to only count the occurance of the last name once.  So:

Count of Dean = 1
Count of Smith = 1"

The pivot table option would do that

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You are absolutely right Shanan212.  And I would likely use a Pivot Table, it's just easier to explain how to use the advanced filter.

And I thought the count might be helpful.
To count a given name, you can use the COUNTIF function:


To generate names, you can use an array function.

Let's say you have rows 1-18 in column A that have a header and a list of names.  You can put this in cell D2 and drag down for as many rows as you think might have unique names - in this case, only 17 rows need be copied down.


Its an array function, so you need CTRL+SHIFT+ENTER to confirm.

with error checking:



See attached.

As suggested, the other alternative is to create a pivot table just to list the unique names, and that would give you the list of the unique names.  That's also in the attached.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.