Log in
x
or
x
x
Register
x

or

 How to count max number of consecutive positive / negative numbers in Excel?

If you have a list of data which mix with positive and negative numbers, and now, you want to count the max number of consecutive positive and negative numbers as following screenshot shown, how could you deal with this task in Excel?

Count the max number of consecutive positive and negative numbers with array formulas


Count the max number of consecutive positive and negative numbers with array formulas


To get the max number of consecutive positive and negative numbers, please apply the following array formulas:

Count the max number of consecutive positive numbers:

Enter this formula into a cell where you want to get the result:

=MAX(FREQUENCY(IF(A2:A20>0,ROW(A2:A20)),IF(A2:A20<=0,ROW(A2:A20)))), and then press Ctrl + Shift + Enter keys together, and you will get the correct result as you need, see screenshot:


Count the max number of consecutive negative numbers:

Enter this formula into a cell where you want to get the result:

=MAX(FREQUENCY(IF(A2:A20<0,ROW(A2:A20)),IF(A2:A20>=0,ROW(A2:A20)))), and then press Ctrl + Shift + Enter keys simultaneously, and you will get the result as you need, see screenshot:

Note: In the above formulas, A2:A20 is the list of cell range which you want to use.


The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Joan · 1 months ago
    Hi, thank you very much for the information! It's very useful :) I wondering if is posible to add up the Max Number of consecutive negatives? I will apreciate a lot if you can help me. Thank you!!
    • To post as a guest, your comment is unpublished.
      skyyang · 1 months ago
      Hi, Joan,
      To solve your problem, please do with the following array formula:

      Sum max number of consecutive positive numbers: (Note: D2 is the cell of the consecutive positive numbers you have counted by the using the formula in this article, please press Ctrl + Shift + Enter keys together)
      =MAX((COUNTIF(OFFSET(A2:A18,ROW(A2:A18)-ROW(A2),0,D2),">=0")=D2)*SUBTOTAL(9,OFFSET($A$2:$A$18,ROW(A2:A18)-ROW($A$2),0,D2)))

      Sum max number of consecutive negative numbers: (Note: E2 is the cell of the consecutive negative numbers you have counted by the using the formula in this article, please press Ctrl + Shift + Enter keys together)
      =MIN((COUNTIF(OFFSET(A2:A18,ROW(A2:A18)-ROW(A2),0,E2),"<0")=E2)*SUBTOTAL(9,OFFSET($A$2:$A$18,ROW(A2:A18)-ROW($A$2),0,E2)))

      Please try, hope it can help you!
  • To post as a guest, your comment is unpublished.
    Abdul Latif · 5 months ago
    how do you count consecutive occurrences of two different values or numbers
  • To post as a guest, your comment is unpublished.
    Ryan · 1 years ago
    How do you do this with multiple rows? say A1:A10 and C1:C10 ???
    • To post as a guest, your comment is unpublished.
      skyyang · 11 months ago
      Hello, Ryan,
      Sorry for that, this formula is only applied to single column or row.
      If you have other good ideals, please comment here.
      Thank you!
  • To post as a guest, your comment is unpublished.
    Ivan · 1 years ago
    Not working! Gives the max number of positive results not consecutive ones
    • To post as a guest, your comment is unpublished.
      skyyang · 1 years ago
      Hi, Ivan,
      The above formula only can help you to count the max number of the positive or negative numbers, it can't extract the consecutive cells.
      If you have the good ways, please comment here.
      Thank you!
  • To post as a guest, your comment is unpublished.
    Leandro · 1 years ago
    Excelente! Funcionou perfeitamente. E se quisermos somar os números de cada intervalo, como ficaria?
  • To post as a guest, your comment is unpublished.
    Shailendra Agrawal · 2 years ago
    I want the consecutive positive numbers from last cell of one column in which data is entered. I will have many column i.e. A,B,C,D,E,F etc
  • To post as a guest, your comment is unpublished.
    Shailendra Agrawal · 2 years ago
    I want the consecutive positive numbers from last of one column. I will have many column i.e. A,B,C,D,E,F etc