+ Reply to Thread
Results 1 to 10 of 10

Counting Unique Values

  1. #1
    Registered User
    Join Date
    11-11-2009
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    8

    Counting Unique Values

    Ok so I have an excel file, that has 20,000 records/rows of data. There is a column called <STATE>, which could be PA, MD, CA, MT, etc.

    I need to know how I can count how many times each state is populated and return the results to a new created sheet called <REPORT>. See example below.

    State:
    PA
    PA
    PA
    MD
    CA
    MT
    NJ
    NJ

    Report Results
    PA 3
    MD 1
    CA 1
    MT 1
    NJ 2

    Can this be done?
    Last edited by Muhnamana; 11-11-2009 at 04:14 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,902

    Re: Counting Unique Values

    Try a Pivot Table..

    http://peltiertech.com/Excel/Pivots/pivotstart.htm

    Drag the State column to Row Area and Drag it again to Data Area...
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Counting Unique Values

    List the state abbreviations in col A1:A50, and in B1 and copy down, =countif(state, A1), where state is the appropriate absolute range on the other sheet.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    11-11-2009
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Counting Unique Values

    Quote Originally Posted by NBVC View Post
    Try a Pivot Table..

    http://peltiertech.com/Excel/Pivots/pivotstart.htm

    Drag the State column to Row Area and Drag it again to Data Area...
    Sweet, this pivot table stuff works perfect.

  5. #5
    Registered User
    Join Date
    11-11-2009
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Counting Unique Values

    Quote Originally Posted by shg View Post
    List the state abbreviations in col A1:A50, and in B1 and copy down, =countif(state, A1), where state is the appropriate absolute range on the other sheet.
    I'll look into this as well.

    Thanks for the helps guys!

  6. #6
    Registered User
    Join Date
    11-11-2009
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Counting Unique Values

    Actually, how can I go about programming this to automatically create the pivot table instead of having to create it each time?

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,902

    Re: Counting Unique Values

    You can right-click in the table and click Refresh Data.

  8. #8
    Registered User
    Join Date
    11-11-2009
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Counting Unique Values

    Yeah I saw the refresh button but there are 4 different excel files which are supplied new to me each month. That's why I want hoping to automatic/program it so I can open the new excel file, click and button and boom, creates the pivot table, prints, emails, etc.

  9. #9
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,902

    Re: Counting Unique Values

    Hopefully someone with better VBA skills than I can help out...

    ...otherwise try posting the specific question automatically refreshing Pivot tables and the other things you want the button to do...

    .. if you do that close this thread and mark solved.

  10. #10
    Registered User
    Join Date
    11-11-2009
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Counting Unique Values

    Alright, thanks. I'll mark this as solved and post another question.

+ 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