+ Reply to Thread
Results 1 to 3 of 3

Summing up positive and negative values

  1. #1
    Registered User
    Join Date
    11-04-2010
    Location
    New York, USA
    MS-Off Ver
    Excel 2003
    Posts
    34

    Summing up positive and negative values

    I have the following values in Column B:
    Column B
    $946
    $(354)
    $2,371
    $421
    $(217)
    $221
    $621
    $(354)
    $(354)
    $(167)

    I want to display the sum of previous positive values if the number changes from positive to negative and sum of negative values when values start changing from negative to positive.

    I am trying to create a result that looks like below:
    Column B Column C
    $946 $946
    $(354) $(354)
    $2,371
    $421 $2,792
    $(217) $(217)
    $221
    $621 $842
    $(354)
    $(354)
    $(167) $(875)

    Is there a way to accomplish this by any formula. Appreciate any help in advance.

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Summing up positive and negative values

    With your sample data beginning in cell B1

    Here's one approach...
    C1: =IFERROR(IF(SIGN(B1)<>SIGN(B2),SUM(INDEX(B:B,LOOKUP(2,INDEX(1/(SIGN(B$1:B1)<>SIGN(B1)),0),ROW(B$1:B1))+1):B1),""),B1)

    Copy that formula down as far as you need.

    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    11-04-2010
    Location
    New York, USA
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Summing up positive and negative values

    That works perfectly, thank you so much.

+ 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