+ Reply to Thread
Results 1 to 7 of 7

Counting last (most recent) consecutive positive or negative numbers in a row

Hybrid View

  1. #1
    Registered User
    Join Date
    07-09-2012
    Location
    michigan
    MS-Off Ver
    Excel 2003
    Posts
    61

    Counting last (most recent) consecutive positive or negative numbers in a row

    I am trying to keep track of the current standings for a fantasy football league. I want to track the current winning/losing streak for each team.

    Therefore I need to count the consecutive positive numbers going backwards from the most recent date for wins, and the same thing going backwards for losses.

    I've included a worksheet with some sample numbers and what the outcomes should be in the cells. The positive numbers are how much a team won by, the negatives are how much they lost by.

    Thanks,
    Damian
    Attached Files Attached Files

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,156

    Re: Counting last (most recent) consecutive positive or negative numbers in a row

    hi again Damian. try this 2 formulas in K7 & M7 respectively:
    =IF(I7>0,COLUMNS($B7:$I7)-MAX(IF($B7:$I7<0,COLUMN($B7:$I7)-1)),"")
    =IF(I7<0,COLUMNS($B7:$I7)-MAX(IF($B7:$I7>0,COLUMN($B7:$I7)-1)),"")

    both are array formulas. that means you got to paste it inside the formula bar, then press CTRL + SHIFT + ENTER to confirm

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Registered User
    Join Date
    07-09-2012
    Location
    michigan
    MS-Off Ver
    Excel 2003
    Posts
    61

    Re: Counting last (most recent) consecutive positive or negative numbers in a row

    benishiryo

    Your solution works if all cells are filled. Unfortunately, we have a 17 week schedule and we've only used 9 weeks thus far. We have blank cells in the row at the end, and your formula doesn't account for that. We only want it to count back from the last cell with a number in it. I've included another example.....would you please take a look for me?

    Thanks,
    Damian
    Attached Files Attached Files

  4. #4
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,156

    Re: Counting last (most recent) consecutive positive or negative numbers in a row

    then try:
    =IF(LOOKUP(99^99,$B$7:$O$7)>0,COUNTA($B$7:$O$7)-MAX(IF($B7:$O7<0,COLUMN($B7:$O7)-1)),"")
    =IF(LOOKUP(99^99,$B$7:$O$7)<0,COUNTA($B7:$O7)-MAX(IF($B7:$O7>0,COLUMN($B7:$O7)-1)),"")

    same thing. CTRL + SHIFT + ENTER

  5. #5
    Registered User
    Join Date
    07-09-2012
    Location
    michigan
    MS-Off Ver
    Excel 2003
    Posts
    61

    Re: Counting last (most recent) consecutive positive or negative numbers in a row

    Benishiryo,

    I appreciate your help, and your formula works when I try it in the examples I've sent you. However, for some reason, and I have no idea why, I can't get it to work in my workbook. Here's the sheet from it I'm trying to compute in.

    In F53:S53 is the range I'm working from. Way over in CY53 and DA53 is where I'm trying to get the results.

    Thanks,
    Damian
    Attached Files Attached Files

  6. #6
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,156

    Re: Counting last (most recent) consecutive positive or negative numbers in a row

    i understand that you try to simplify the example, but many factors can affect the results. like the change in column or if there's a formula in it. you can still do up a sample, but considering all these factors if possible. i do love reading a simplified eg. try these now:
    =IF(INDEX($F$53:$S$53,COUNTIF($F$53:$S$53,"<>0"))>0,COUNTIF(F53:S53,"<>0")-MAX(IF($F53:$S53<0,COLUMN($F53:$S53)-5)),"")
    =IF(INDEX($F$53:$S$53,COUNTIF($F$53:$S$53,"<>0"))<0,COUNTIF($F$53:$S$53,"<>0")-MAX(IF($F53:$S53>0,COLUMN($F53:$S53)-5)),"")
    Last edited by benishiryo; 11-13-2012 at 07:12 AM.

  7. #7
    Registered User
    Join Date
    07-09-2012
    Location
    michigan
    MS-Off Ver
    Excel 2003
    Posts
    61

    Re: Counting last (most recent) consecutive positive or negative numbers in a row

    Fantastic! I have it fully functional now! Super!

    Thank you so very much!

    Damian

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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