Calc - Count a "similar sequence"

Is there a way to count a sequence of data as long as they are similar?
We have a datasheet were the sales of our sales men are imported.
One of the information we’re using is counting for how long one sales man
has been on top.

Ex.:
Sales man#1
Sales man#1
Sales man#1
Sales man#2
Sales man#1
Sales man#3

Is here a way that calc can detect that the data is changing and stop the
counting?
The above sample should return 3

Looking forward to any suggestion.

I often do counting in a secondary column.

See the attached file for a possible solution:
length_of_longest_run.ods
<http://nabble.documentfoundation.org/file/n4185405/length_of_longest_run.ods>

cje wrote:

> Is there a way to count a sequence of data as long as they are similar?
> We have a datasheet were the sales of our sales men are imported.
> One of the information we’re using is counting for how long one sales man
> has been on top.
>
> Ex.:
> Sales man#1
> Sales man#1
> Sales man#1
> Sales man#2
> Sales man#1
> Sales man#3
>
> Is here a way that calc can detect that the data is changing and stop the
> counting?
> The above sample should return 3
>
> Looking forward to any suggestion.

You can write a macro for that, e.g. in Basic.

Here is one for the above problem:

[resent; for some reason the first copy's not appeared on the list. Apologies if it appears twice.]

I often do counting in a secondary column.

See the attached file for a possible solution:
length_of_longest_run.ods
<http://nabble.documentfoundation.org/file/n4185405/length_of_longest_run.ods>

A lot depends on the OP's needs.

If it's a once in a blue moon computation, there's a lot to said for keeping things simple: export the salesman name column to a flat text file, and run it through 'uniq -c' (OK, 'nix-specific, but nevertheless available for windows).

But the OP did actually specify "similar", not "identical", in which case one is entering very murky waters, and a precise definition of 'similar' is needed.