View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Count duplicates in an array?

If we are talking all worksheet cells here, and say the array is in M1:M8,
then use

=COUNTIF($M$1:$M$8,A1)

--

HTH

RP
(remove nothere from the email address if mailing direct)


"quartz" wrote in message
...
I am using Office 2003 on Windows XP.

I need to be able to count the number of each item in a single element
array, then write out the counts.

For example, if the array contains:
Red, Blue, Red, Orange, Orange, Red, Green, Blue

My result would be:
A1: Red B1: 3
A2: Blue B2: 2
A3: Orange B3: 2
A4: Green B4: 1

If anyone has a function to which I could pass my array to output the

counts
or could share some code I could adapt it would be most appreciated.

Thanks much in advance.