+ Reply to Thread
Results 1 to 7 of 7

Sum 7 left cells or up to the first negative number

  1. #1
    Registered User
    Join Date
    02-03-2013
    Location
    Montreal, canada
    MS-Off Ver
    Excel 2003
    Posts
    3

    Sum 7 left cells or up to the first negative number

    Hello,

    I'd like to sum the first 7 left cells or up to the first negative number (always to a max of 7 cells)

    EX. =SUM(A1:G1) to cell G2 This is pretty much easy
    My problem is, if there is a negative number in these 7 cells, I have to sum up before that cell without counting it or going over it.

    A1= 1
    A2= 2
    A3=(-2)
    A5= 2
    A6= 3
    A7= 4
    Total on Cell G3 would have to be 9
    A7+A6+A5=9 since A3=(-2) I only count before the first negative number

    Is there an easy way to do that?

    Thank you

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,106

    Re: Sum 7 left cells or up to the first negative number

    What about A4?
    Never use Merged Cells in Excel

  3. #3
    Registered User
    Join Date
    02-03-2013
    Location
    Montreal, canada
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Sum 7 left cells or up to the first negative number

    OOOps,

    Just forgot to add it in

    In that case, I would need to add it up until the first negative number

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Sum 7 left cells or up to the first negative number

    try
    =SUM(OFFSET(A1,LOOKUP(2,1/(A1:A7<0),ROW(A1:A7)),,7-LOOKUP(2,1/(A1:A7<0),ROW(A1:A7))))
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,447

    Re: Sum 7 left cells or up to the first negative number

    Hi 10ml,

    Find the attached with a helper column and what I think you want as an answer.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  6. #6
    Registered User
    Join Date
    02-03-2013
    Location
    Montreal, canada
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Sum 7 left cells or up to the first negative number

    Drivers.xls

    Thank You,

    I Think I gave you the wrong info

    I need the total of the seven previous column of row 6 and the total on row 7
    In my example, I sum up every 7 previous column but it is substracting the negative number



    Hope you understand my example!

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,199

    Re: Sum 7 left cells or up to the first negative number

    Hi, 10ml,

    according to Forum Rule #8 you should have included the link to your other thread as this thread was posted 2 minutes later.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ 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