title: Count the number of sequences in a range
body: <p>I would like to count the number of sequences in a dataset.
  A new sequence is started whenever a the value changes from zero to positive or from positive to zero.</p>
  <p>The data represent mm rain one entry for every hour of the day.
  If it starts raining a new sequence starts, if it stops raining a new sequence starts as well.
  On some days it keeps raining (1 sequence of rain, 0 sequences of dry).
  On others days it will be dry (0 sequence of rain, 1 sequence of dry).
  The other days will have X sequences of rain and Y sequences of dry (X and Y differ 0 or 1).</p>
  <p>Example:
  Range (N1:N25) contains</p>
  <pre><code>RH
  0
  0
  0
  0
  0
  0
  1
  3
  9
  2
  0
  0
  0
  0
  0
  0
  2
  0
  0
  0
  0
  0
  0
  0
  </code></pre>
  <p>Using Matrix formulas I can calculate
  The longest sequence of non-zero's, being 4, by</p>
  <pre><code>=MAX(FREQUENCY(IF($N$2:$N$25&gt;0,ROW($N$2:$N$25)),IF($N$2:$N$25&lt;=0,ROW($N$2:$N$25)))
  </code></pre>
  <p>but i cannot calculate the number of sequences of non-zero's, being 2, nor the total number of sequences, being 5.</p>
  <p>How can I do that?</p>
  <p>I looked for the answer on Stackoverflow but couldn't find it</p>