+ Reply to Thread
Results 1 to 16 of 16

SUMIF formula returning negative value & I need it to be positive

  1. #1
    Registered User
    Join Date
    07-10-2013
    Location
    Memphis, TN
    MS-Off Ver
    Excel 2010
    Posts
    34

    SUMIF formula returning negative value & I need it to be positive

    Hello, I found this formula on the internet and changed it for my purpose:

    =SUMIF($M:$M,"="&"D",$F:$F)+SUMIF($M:$M,"="&"A",$F:$F)-SUMIF($N:$N,"<>""0")-$H$3

    The value it returns is correct, except that it is a negative and I need it to be a positive. The numbers in column M are actually negatives that I'm adding together in the first 2 SUMIF statements. The numbers in column N are positive and the number in cell H3 is positive. So, taking in consideration of the SUMIF conditions of my formula, I really need the formula to work this way:

    Cell H3 - Column M + Column N

    I have tried several variations of *-1 with the $H$3 cell reference at the end of the formula (to change the polarity) and the result remains a negative or it returns a positive with an incorrect dollar amount.

    I have a visual basic code that will reverse the "polarity" but I was hoping there a way to modify my formula to do that.

    I hope this makes sense and that I have provided enough infomation. Please let me know if you need additional information.

    Thanks!

    Debbie

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: SUMIF formula returning negative value & I need it to be positive

    Maybe:

    =-(SUMIF($M:$M,"="&"D",$F:$F)+SUMIF($M:$M,"="&"A",$F:$F)-SUMIF($N:$N,"<>""0")-$H$3)


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: SUMIF formula returning negative value & I need it to be positive

    Hi Debbie & Welcome to the forum,

    Maybe wrap your function in ABS.
    HTH
    Regards, Jeff

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: SUMIF formula returning negative value & I need it to be positive

    Try

    =SUMIF($N:$N,"<>0")+$H$3-SUM(SUMIF($M:$M,{"A","D"},$F:$F))
    Audere est facere

  5. #5
    Registered User
    Join Date
    07-10-2013
    Location
    Memphis, TN
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: SUMIF formula returning negative value & I need it to be positive

    Hi, Trevor. THAT IS IT! I knew it was something very simple - the negative added to the front of the formula! I'm not that good with formulas but I can usually find what I need by searching the internet.

    Hi, Jeffrey. Thank you for the welcome and suggestion! I DID try ABS but again, I am not that good with formulas and couldn't figure out how to work it into my formula.

    Thank you both for your help and suggestions!!

  6. #6
    Registered User
    Join Date
    07-10-2013
    Location
    Memphis, TN
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: SUMIF formula returning negative value & I need it to be positive

    And thank you for your suggestion too, Daddylonglegs!

    You guys are awesome!!

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

    Re: SUMIF formula returning negative value & I need it to be positive

    SUMIF($N:$N,"<>""0")????? surely thats just sum($N:$N)
    "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

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: SUMIF formula returning negative value & I need it to be positive

    You're welcome.


    I think, if you look closely, you can combine several of the suggestions to get a shorter formula that does the same thing.



    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


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  9. #9
    Registered User
    Join Date
    07-10-2013
    Location
    Memphis, TN
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: SUMIF formula returning negative value & I need it to be positive

    Quote Originally Posted by martindwilson View Post
    SUMIF($N:$N,"<>""0")????? surely thats just sum($N:$N)
    Yes, Martin, I did realize that was "dumb" but I'm not good at creating formulas so I copied it from the internet and once it gave me the total I needed, I kinda stopped changing it, except for the polarity problem. Thanks for confirming that.

  10. #10
    Registered User
    Join Date
    07-10-2013
    Location
    Memphis, TN
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: SUMIF formula returning negative value & I need it to be positive

    Thank you all - I REALLY do appreciate everyone's help!

    Now I need to insert the formula into a VBA module. This doesn't seem to work:

    Range("D7").Formula = "=-(SUMIF($M:$M,"="&"D",$F:$F)+SUMIF($M:$M,"="&"A",$F:$F)-SUM($N:$N)-$H$3)"

    Am I missing something simple again?
    Last edited by dosbirn; 07-11-2013 at 11:41 AM. Reason: typo

  11. #11
    Registered User
    Join Date
    07-10-2013
    Location
    Memphis, TN
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: SUMIF formula returning negative value & I need it to be positive

    Trevor, I assume you meant the star next to "Add Reputation". If so....done!

    I will remember to mark the thread solved once my VBA question is resolved. Thank you for the forum help!!
    Last edited by dosbirn; 07-11-2013 at 12:13 PM.

  12. #12
    Registered User
    Join Date
    07-10-2013
    Location
    Memphis, TN
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: SUMIF formula returning negative value & I need it to be positive

    Quote Originally Posted by dosbirn View Post
    Now I need to insert the formula into a VBA module. This doesn't seem to work:

    Range("D7").Formula = "=-(SUMIF($M:$M,"="&"D",$F:$F)+SUMIF($M:$M,"="&"A",$F:$F)-SUM($N:$N)-$H$3)"
    I'm not sure if the above post was missed because I posted another after it.

    I even tried using Daddylonglegs' suggested formula below (which also works in the spreadsheet).

    Range ("D7").formula = "=SUMIF($N:$N,"<>0")+$H$3-SUM(SUMIF($M:$M,{"A","D"},$F:$F))"

    Is it too difficult to add a formula (in this way) to a module? Does it need to be converted into code instead?

    I'm sorry but I have limited experience with Excel formulas and VBA.

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

    Re: SUMIF formula returning negative value & I need it to be positive

    Please Login or Register  to view this content.
    Last edited by martindwilson; 07-11-2013 at 02:52 PM.

  14. #14
    Registered User
    Join Date
    07-10-2013
    Location
    Memphis, TN
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: SUMIF formula returning negative value & I need it to be positive

    You rock, Martin! That worked! Thank you so much.

    Whew! Now I should be able to close this thread and move on to tackle to the next issue I run across. hahaha

  15. #15
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: SUMIF formula returning negative value & I need it to be positive

    Thanks for the rep.

  16. #16
    Registered User
    Join Date
    07-10-2013
    Location
    Memphis, TN
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: SUMIF formula returning negative value & I need it to be positive

    Quote Originally Posted by TMShucks View Post
    Thanks for the rep.
    YW....but thank YOU for your help!

+ 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