View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Glenn Glenn is offline
external usenet poster
 
Posts: 1,240
Default Count subset-totals in column

Pluggie wrote:
I have a column with data.
The data consists of incremental numbers:

Column A

1
2
3
4

1
2

1
2
3

What I want to do in column B is count the number of instances of each subset.
Result would look like this:

Column A Column B
4
1
2
3
4
2
1
2
3
1
2
3

The largest subset consists of 9 instances.

I tried reaching a solution using CountIf and nested If-statements, but
without any luck. Anybody have any bright ideas?

by the way 1:
I do have the add-on morefucntions, but didn't recognize a usefull fuction
in there either).

by the way 2: I could replace the numbers with a single character if that
would help simplify this issue.

Thanks in advance for your help.


If there are now blank rows between subsets and the data starts in row 2, put
this in B2 and copy down (replace the 1000's with the number of rows in your data):

=IF(A2=1,IF(ISNUMBER(MATCH(1,A3:$A$1000,0)),
MATCH(1,A3:$A$1000,0),COUNT(A2:$A$1000)),"")

If there are blank rows between subsets, subtract 1 from the MATCH() result:

=IF(A2=1,IF(ISNUMBER(MATCH(1,A3:$A$1000,0)),
MATCH(1,A3:$A$1000,0)-1,COUNT(A2:$A$1000)),"")