+ Reply to Thread
Results 1 to 7 of 7

Counting max consecutive positive and negative number in a row.

  1. #1
    Registered User
    Join Date
    11-07-2019
    Location
    france
    MS-Off Ver
    2019
    Posts
    8

    Counting max consecutive positive and negative number in a row.

    Hello all,

    I need to count the largest number of consecutive positive numbers in k3 and negative numbers in k7.

    I also need the sheet to update in real time.

    I did not find the solution online.

    Thank you.
    Attached Files Attached Files

  2. #2
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Counting max consecutive positive and negative number in a row.

    Please try at
    K3
    =MAX(FREQUENCY(IF(K10:K19>0,ROW(K10:K19)),IF(K10:K19<=0,ROW(K10:K19))))
    Press Ctrl+Shift+Enter

    K7
    =MAX(FREQUENCY(IF(K10:K19<0,ROW(K10:K19)),IF(K10:K19>=0,ROW(K10:K19))))
    Press Ctrl+Shift+Enter
    Attached Files Attached Files

  3. #3
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: Counting max consecutive positive and negative number in a row.

    I added a helper column with this formula:

    HTML Code: 
    Then it a matter of picking the Max and Min values.

    See attached and hope it works for you.
    Attached Files Attached Files
    1. Click on the * Add Reputation if you think this helped you
    2. Mark your thread as SOLVED when question is resolved

    Modytrane

  4. #4
    Registered User
    Join Date
    11-07-2019
    Location
    france
    MS-Off Ver
    2019
    Posts
    8

    Re: Counting max consecutive positive and negative number in a row.

    Thx a lot, it works but I ran in another problem, when I use "","" to remove the zeros in the sheet it's counted as positive number, maybe there's an easy fix that still allow me to use "","", since I use it in other sheet also ?
    Attached Files Attached Files

  5. #5
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Counting max consecutive positive and negative number in a row.

    Please try at L3
    =MAX(FREQUENCY(IF((K10:K9999>0)*(K10:K9999<>""),ROW(K10:K9999)),IF(K10:K9999<=0,ROW(K10:K9999))))

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Counting max consecutive positive and negative number in a row.

    Another approach that eliminates / ignores the "" is to define a dynamic named range (DNR) in Name Manager.

    In the attached please find a DNR that I named NumRng.
    It is defined as

    NumRng
    =Sheet1!$K$10:INDEX(Sheet1!$K:$K,MATCH(1E+306,Sheet1!$K:$K,1))


    Then array enter these modifications of Bo_Ry's:
    For the Max positive
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    the Max negative
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Dave

  7. #7
    Registered User
    Join Date
    11-07-2019
    Location
    france
    MS-Off Ver
    2019
    Posts
    8

    Re: Counting max consecutive positive and negative number in a row.

    It work great.
    Thank you all for your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. CountA - stop counting in column when number changes positive or negative
    By Hallgente in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-26-2016, 01:04 PM
  2. Replies: 1
    Last Post: 04-14-2015, 08:34 PM
  3. Counting number of users with positive/negative outcomes
    By iainwall in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-09-2014, 05:24 PM
  4. [SOLVED] Find consecutive 15 positive or negative numbers in a column
    By Sarangsood in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-19-2013, 05:26 AM
  5. [SOLVED] Count Consecutive Positive/Negative numbers
    By Taislin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-16-2013, 01:02 PM
  6. Sum of time for consecutive positive/ negative numbers
    By DexterG in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-25-2012, 04:03 AM
  7. Replies: 6
    Last Post: 11-13-2012, 07:33 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1