Solved

Count unique cells

Posted on 2011-02-14
8
431 Views
Last Modified: 2012-05-11
I have a table consisting of

Name | Company | Tel
Mr A | Giant Corp | 1234
etc...

I would like some vb to count the amount of unique values in the company column.
Starting from row 2 to whatever the last row with data is.

Kind regards,
Antonio
0
Comment
Question by:cbsbutler
8 Comments
 
LVL 17

Expert Comment

by:gtgloner
Comment Utility
Have a look at this file:
Book1.xls
0
 
LVL 33

Expert Comment

by:jppinto
Comment Utility
Why do you need to do it with a macro?! Can't you do it with a formula? You could use SUMPRODUCT() or SUMIFS():

http://excel-user.blogspot.com/2011/02/sumif-and-sumifs-functions.html
http://excel-user.blogspot.com/2009/10/sumproduct-sum-values-based-on.html

jppinto
0
 
LVL 17

Accepted Solution

by:
gtgloner earned 250 total points
Comment Utility
...one little glitch in the previous file, use this instead:
Book1.xls
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 45

Assisted Solution

by:patrickab
patrickab earned 250 total points
Comment Utility
cbsbutler,

I hope gtloner doesn't mind but I've used his file (attached) to show another way of doing it using a Collection.

Patrick
Sub uv()
Dim rng As Range
Dim celle As Range
Dim coll As New Collection

With Sheets("Sheet1")
    Set rng = Range(.Cells(2, "B"), .Cells(.Rows.Count, "B").End(xlUp))
End With

For Each celle In rng
    On Error Resume Next
    coll.Add celle, celle
Next celle

MsgBox "Number of unique entries in the Company column = " & coll.Count

End Sub

Open in new window

Copy-of-Book1-4-02.xls
0
 
LVL 17

Expert Comment

by:gtgloner
Comment Utility
Don't worry Patrick, I'm not holding any patents here  : - )
0
 
LVL 45

Expert Comment

by:patrickab
Comment Utility
gtgloner,

Thanks for that generous response.

Patrick
0
 
LVL 24

Expert Comment

by:broomee9
Comment Utility
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ms sql stored procedure 22 75
Auto Operation of MS Excel 2013 2 29
Checkbox Notification 3 22
Populate data based ona  criteria 6 17
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now