+ Reply to Thread
Results 1 to 4 of 4

Count unique combinations

  1. #1
    Registered User
    Join Date
    12-14-2009
    Location
    NY,NY
    MS-Off Ver
    Excel 2003
    Posts
    2

    Post Count unique combinations

    I have the following dataset:

    ColA-ID ColB-Yr
    6101920 1984
    6101920 1985
    7812235 2001
    7812235 2002
    8812345 1960
    8812345 1960

    I'm hoping someone can here help me figure out what I'm assuming is a simple macro would look like if I wanted it to give me the number of unique combinations of ID & Yr in the rows of data shown above. The expected result would be 5 (from a total of 6 shown) and it would be shown in another cell within the same worksheet.

    Thanks for your help!
    Last edited by macanudo67; 12-14-2009 at 06:48 PM. Reason: Non-descriptive title?

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Count unique combinations

    Why use VBA code when this can be done quickly using a Pivot Table?
    Attached Files Attached Files
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Count unique combinations

    If needed, one formula approach might be:

    Please Login or Register  to view this content.
    (assumes pre 2007 version per profile)

  4. #4
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: Counting unique combinations of two cell values

    Hi,

    No need for code:

    In C1 enter =A1&B1

    copy down the length of your data

    then use this array (using CTRL, SHIFT and ENTER) to count unique values.

    =SUM(1/COUNTIF(C1:C5,C1:C5))

    adjust the range C1:C5 to suit
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1