+ Reply to Thread
Results 1 to 4 of 4

Count Consecutive Positive/Negative numbers

  1. #1
    Forum Contributor
    Join Date
    06-25-2012
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2010
    Posts
    201

    Count Consecutive Positive/Negative numbers

    Hi.

    I'm trying to count a number of consecutive profit/loss in a collumn
    In another post i found this solution which i addapted for my workbook.

    Let's say in collumn A i have the following numbers from A2:A12
    A2: 0
    A3: 2
    A4: 1.5
    A5: -3.5
    A6: 1
    A7: 5
    A8: 10
    A9: 4.5
    A10: 0.5
    A11:-1
    A12: -2


    Now to get the max of consecutive positive number i put the nxt array formula in B1:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    And this will give me the result 5, which is the max number of consecutive positive numbers.

    Now, to get the max sum value in that range i put the next array formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    And it will say that for the 5 consecutive positive numbers i got the total sum of 21 (1+5+10+4.5+0.5)

    Untill here its ok.

    But how about negative numbers?
    For the first formula its easy. Just replaced the > for < and the <= for >= and it was ok. But for the second formula this was not enough. I don't know if i have to replace the SMALL fucntion or change also the minus on -B1-1 for +. Anyway, just by changing < to > or <= to >= didn't worked, because gave me the error N/A. So, something must be missing.

    So if someone could please help me how to put the formula correct i would be really appreciated.
    Thank you.

  2. #2
    Forum Contributor
    Join Date
    06-25-2012
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2010
    Posts
    201

    Re: Count Consecutive Positive/Negative numbers

    Forget about it. Just figured it out. Thanks anyway.

  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Count Consecutive Positive/Negative numbers

    If you solve a problem yourself before anyone else has responded, please take a moment to describe your solution, chances are some other member will benefit.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  4. #4
    Forum Contributor
    Join Date
    06-25-2012
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2010
    Posts
    201

    Re: Count Consecutive Positive/Negative numbers

    It was simple. I just change the > to < in both formulas. The problem i was having in the second formula it was because i was introducing bad references of cells values in the formula. But it is just simples as changing the operators i said above and the formula will work as expected.

+ 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. 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
  2. count the series of consecutive positive/negative values and sum them
    By otage in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 12-12-2012, 12:43 PM
  3. Replies: 6
    Last Post: 11-13-2012, 07:33 AM
  4. Replies: 5
    Last Post: 09-01-2011, 03:46 AM
  5. Replies: 3
    Last Post: 06-17-2010, 03:04 PM

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