+ Reply to Thread
Results 1 to 7 of 7

Trying to sum result of a range but only if positive

  1. #1
    Registered User
    Join Date
    11-07-2023
    Location
    Tennessee
    MS-Off Ver
    2019
    Posts
    4

    Trying to sum result of a range but only if positive

    Hi everyone,
    I'm not great at this and I've stumped myself. I think I'm close though, just missing one part.
    I'm trying to add up the results of rows 6-50 of the following:

    (F6/C6*0.024)-50 + (F7/C7*0.024)-50 etc but ONLY if it's a positive value. So if subtracting 50 makes it negative, I need it to be ignored rather than subtract from the sum.

    So far I have:
    =SUM(IF(C6:C50<>0,((F6:F50/(C6:C50*0.024))-50)))
    Which is working except the negative values. The first IF is only to stop division by zero for blank lines.
    I've tried adding an extra IF ">0" statement but that results in SPILL!
    I've tried adding a MAX(0,all that^) but it just returns the first line it finds, the sum doesn't seem to continue.

    I'm really hoping someone can spot my mistake, or send me down a different rabbit hole!
    Thanks!
    -Byron

  2. #2
    Forum Contributor
    Join Date
    02-20-2022
    Location
    Indonesia
    MS-Off Ver
    Excel 2016
    Posts
    110

    Re: Trying to sum result of a range but only if positive

    Please Login or Register  to view this content.
    Can you make the example of the result that you want?

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2407
    Posts
    25,816

    Re: Trying to sum result of a range but only if positive

    First, your example formula does a different calculation than what you have earlier in your description:

    (F6/C6*0.024)-50
    is equivalent to this
    ((F6/C6)*0.024)-50

    but then this
    (F6:F50/(C6:C50*0.024))-50
    adds parentheses that change the calculation.

    Please confirm what calculation you actually want.

    I tested this with a little bit of fake data. If I had your data I would have a better test. Consider providing a sample file. This uses the calculation in your first description. It is an array formula. I don't know what Excel 2019 supports but you may have to explicitly enter it as an array formula with CTRL+SHIFT+ENTER.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Registered User
    Join Date
    11-07-2023
    Location
    Tennessee
    MS-Off Ver
    2019
    Posts
    4

    Re: Trying to sum result of a range but only if positive

    Thanks Jeff,
    The second formula is the one I'm after. The 0.024 is in the denominator. The code you sent back is returning 0 right now, going over it but thanks!

  5. #5
    Registered User
    Join Date
    11-07-2023
    Location
    Tennessee
    MS-Off Ver
    2019
    Posts
    4

    Re: Trying to sum result of a range but only if positive

    Here's the relative part of the sheet with a few notes, I know it doesn't make a whole lot of sense but hopefully that explains a little.
    Thanks again!
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    11-07-2023
    Location
    Tennessee
    MS-Off Ver
    2019
    Posts
    4

    Re: Trying to sum result of a range but only if positive

    Quote Originally Posted by BMagedanz View Post
    Thanks Jeff,
    The second formula is the one I'm after. The 0.024 is in the denominator. The code you sent back is returning 0 right now, going over it but thanks!
    Scratch that, just had to adjust a few parentheses to make it run the second formula and not only does it work perfectly, it's beautifully simplistic. THANK YOU!

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2407
    Posts
    25,816

    Re: Trying to sum result of a range but only if positive

    Glad it worked! Post back to this thread if you see a problem. (The formula could be slightly simplified with the LET function but that's not available in your version.)

+ 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. [SOLVED] Multiplying two columns and countif result is positive
    By GWCollo in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-21-2022, 08:07 AM
  2. [SOLVED] Yes No IF Problem w/positive or negative result
    By Spinette in forum Excel General
    Replies: 2
    Last Post: 09-28-2015, 02:27 PM
  3. Replies: 3
    Last Post: 01-08-2014, 06:59 PM
  4. [SOLVED] Calculate VAT keeping the result positive and going to the last row
    By markDuffy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-30-2013, 07:19 PM
  5. count result as zero unless positive value
    By jimb0693 in forum Excel General
    Replies: 3
    Last Post: 07-07-2009, 05:36 AM
  6. Replies: 1
    Last Post: 06-09-2006, 08:10 AM
  7. [SOLVED] Cell formula where result to be Positive only
    By Freddie in forum Excel General
    Replies: 4
    Last Post: 02-01-2006, 11:45 AM

Tags for this Thread

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