Counting sequences of values

MetricsGuy

New Member
Joined
Dec 9, 2010
Messages
2
I want to count a mixed sequence of values contained in a single column and show how many of each value occur, in order. Here's some sample data and desired output:

Sample data:
A
A
A
B
A
B
B
A
A
B

Desired output:
A 3
B 1
A 1
B 2
A 2
B 1

How can this be done (preferably not using VBA, but if that's how it needs to be done, so be it)?

Thanks.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
If your column of letters is A1:A100, then maybe in C1:

C1: =A1

and in D1 (confirmed with Ctrl+Shift+Enter):

D1: =MATCH(TRUE,A1:A100<>C1,0)-1

and then in C2:

=OFFSET(A$1,SUM(D$1:D1),0)

and in D2 (confirmed with Ctrl+Shift+Enter):

=MATCH(TRUE,OFFSET(A$1,SUM(D$1:D1),0,100)<>C2,0)-1

and then fill C2 and D2 as far down as needed.

Pretty quick and dirty solution to be honest, but maybe a starting point.

edit...

you could tidy up the C2 and D2 formulae a bit with:

C2: =OFFSET(A$1,SUM(D$1:D1),0)&""
D2: =IF(C2="","",MATCH(TRUE,OFFSET(A$1,SUM(D$1:D1),0,100)<>C2,0)-1)
 
Last edited:
Upvote 0
Yup, quick and dirty worked great. Many thanks!

Any recommended reading for me to understand how the "confirmed" functionality works? I'm not accustomed to array handling but am interested in learning. Can't quite get my brain wrapped around embedding ranges in functions (except those like SUM()).
 
Upvote 0

Forum statistics

Threads
1,216,823
Messages
6,132,920
Members
449,768
Latest member
LouBa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top