How to count consecutive values in Excel?

Asked

Viewed 791 times

0

Right now I have this formula that calculates consecutive values:

=SE(AB5=0;0;SE(OU(E(AB4>=100;AB5>=100);E(AB4<=-100;AB5<=-100));AC4+1;1))

Basically she does this:

0           0
0           0
-110        1
-110        2
-110        3
-100        4
0           0
0           0
0           0
130         1
150         2
0           0
0           0
-100        1
0           0
0           0
0           0
0           0
-110        1
0           0
0           0
0           0
-220        1
-150        2
0           0
0           0

But I intend for her to do this:

0           0
0           0
-110        0
-110        0
-110        0
-100        4
0           0
0           0
0           0
130         0
150         2
0           0
0           0
-100        1
0           0
0           0
0           0
0           0
-110        1
0           0
0           0
0           0
-220        0
-150        2
0           0
0           0

Or this:

0           0
0           0
-110        4
-110        0
-110        0
-100        0
0           0
0           0
0           0
130         2
150         0
0           0
0           0
-100        1
0           0
0           0
0           0
0           0
-110        1
0           0
0           0
0           0
-220        2
-150        0
0           0
0           0

What is the formula to make this possible ?

I would prefer not to have to add more columns, because the file is already large...

Using only one formula to do this job would be best...

Thanks for the help.

  • 3

    Hello Fabio, this is the site of Stackoverflow in Portuguese, translate your question

  • I already translated the question.

  • good Fabio, otherwise it may be pending because it is signed as written in another language, now it is ok :)

1 answer

1

For the formula not to get too extensive you can use another column to compare lines, two by two, as the image below:

inserir a descrição da imagem aqui

  • Thiago, I think I’ll put this solution even. I’ve tried with just one column and everything results in very slow formulas. Thank you, gashaste an upvote, because although not quite what is in the question, your solution solves the problem.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.