+ Reply to Thread
Results 1 to 8 of 8

Sum every other row in a range if value of every other cell is greater than 0

  1. #1
    Registered User
    Join Date
    07-16-2004
    Location
    Hampshire, England
    MS-Off Ver
    2007
    Posts
    29

    Sum every other row in a range if value of every other cell is greater than 0

    Hi
    I want to sum the values of every other cell in a range, but only if all the cells in the every other cell range have a value greater than 0, eg.

    A B
    1 3
    4 2
    4 0
    2 1

    In column A, both the first and third cells contain a value greater than 0, so the value returned would be 5.
    In column B, the first cell contains a value greater than 0, but the third cell does not, so the value returned would be "test not completed".

    I have this so far....
    Please Login or Register  to view this content.
    but this checks every cell in the range is >0 and not every other.

    Thanks

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

    Re: Sum every other row in a range if value of every other cell is greater than 0

    MOD(ROW(),2) =1 for odd rows 0 for even rows
    so
    =IF(SUMPRODUCT((MOD(ROW(A1:A10),2)=1)*(A1:A10=0)),"not complete",SUMPRODUCT((MOD(ROW(A1:A10),2)=1)*(A1:A10)))
    no blanks allowed unless you intentionally want them because blank =0
    mind you to ignore blanks
    =IF(SUMPRODUCT((MOD(ROW(A1:A10),2)=1)*(A1:A10=0)*(A1:A10<>"")),"not complete",SUMPRODUCT((MOD(ROW(A1:A10),2)=1)*(A1:A10)))
    Attached Files Attached Files
    Last edited by martindwilson; 07-06-2012 at 05:30 AM.
    "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

  3. #3
    Valued Forum Contributor
    Join Date
    04-30-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    547

    Re: Sum every other row in a range if value of every other cell is greater than 0

    Or maybe

    Please Login or Register  to view this content.
    Like a post? Click the star below it!

  4. #4
    Registered User
    Join Date
    07-16-2004
    Location
    Hampshire, England
    MS-Off Ver
    2007
    Posts
    29

    Re: Sum every other row in a range if value of every other cell is greater than 0

    Thanks Martin, that's great!

    I was forgetting about blanks (of which there are a few) - how can I treat blanks the same as 0 ie blanks would return the value "not completed" rather than being ignored?
    Regards
    Emma

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

    Re: Sum every other row in a range if value of every other cell is greater than 0

    use the first formula as i said it counts blanks as zero
    =IF(SUMPRODUCT((MOD(ROW(A1:A10),2)=1)*(A1:A10=0)),"not complete",SUMPRODUCT((MOD(ROW(A1:A10),2)=1)*(A1:A10)))

  6. #6
    Registered User
    Join Date
    07-16-2004
    Location
    Hampshire, England
    MS-Off Ver
    2007
    Posts
    29

    Re: Sum every other row in a range if value of every other cell is greater than 0

    many thanks!

  7. #7
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Sum every other row in a range if value of every other cell is greater than 0

    You don't say which version of excel you're using, with 2007 or later

    =IFERROR(SUM(IF(MOD(ROW(C$11:C$89),2),1/(1/C$11:C$89))),"not complete")

    Which must be array confirmed using Shift Ctrl Enter.

  8. #8
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Sum every other row in a range if value of every other cell is greater than 0

    @emm8080

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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