View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernard Liengme[_2_] Bernard Liengme[_2_] is offline
external usenet poster
 
Posts: 563
Default Count how many instances of an item appear in a range

Do you really want a macro?
You could use Filter/Unique to get a list of unique state names (if needed)
Let's say the first unique state name is pasted to G5
If you data is in A1:E400 with state in column C
In H5 enter =COUNTIF(C1:C400,G5) to get the count
best wishes
--
Bernard Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme

"Jon" wrote in message
...
I have a spreadsheet with 4 columns: name,city state, and age.
Let's say I have 350 rows. I have sorted the rows by State. What I
want to do is count the number of times each state appears in the
state column and place the results somewhere else.
Example:
John Doe California
Pete Smith California
Dan Doe California
Jane Dill Idaho
Bill Will Nevada
Dan John Nevada
etc.....

I need a macro that will place in another location (let's say starting
a cell G5) the following
California 3
Idaho 1
Nevada 2

Thanks for any help you can give.
Jonco