+ Reply to Thread
Results 1 to 14 of 14

Subtraction Formula

  1. #1
    Forum Contributor
    Join Date
    02-25-2007
    Posts
    106

    Subtraction Formula

    Hey Everyone,

    I need a formula for this:

    B2-B1 answer in C2 but it will not display a negative number.

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Subtraction Formula

    Try

    =MAX(0,B2-B1)

  3. #3
    Forum Contributor
    Join Date
    02-25-2007
    Posts
    106

    Re: Subtraction Formula

    So far so good.

    But, if I enter data in say B2 but have not in B1 yet, how do I stop C2 from displaying what I entered in B2?

  4. #4
    Forum Contributor
    Join Date
    02-25-2007
    Posts
    106

    Re: Subtraction Formula

    So far so good.

    But, if I enter data in say B2 but have not in B1 yet, how do I stop C2 from displaying what I entered in B2?

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,944

    Re: Subtraction Formula

    =if(and(b2="",B1=""),"",B2-B1)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  6. #6
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,477

    Re: Subtraction Formula

    May be:
    =IF(OR(B1="",B2=""),"",MAX(0,B2-B1))
    Quang PT

  7. #7
    Forum Contributor
    Join Date
    02-25-2007
    Posts
    106

    Re: Subtraction Formula

    Thanks bebo,

    How do I get it to display a 0?

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,944

    Re: Subtraction Formula

    Quote Originally Posted by Dowjd View Post
    Hey Everyone,

    I need a formula for this:

    B2-B1 answer in C2 but it will not display a negative number.
    OK do you mean you dont WANT it to show a negative answer, or that it just will not show a negative number?

    If you want it to NOT show a neg number, then use this...
    =if(b2-B1>0,"",B2-B1) (you can change "" for 0 if you want)

    If you want it to show a positive number (not a negative number) no matter what the answer is, then use this...

    =abs(B2-B1) this will show 3-1 as 2 and 1-3 as 2 (not -2)

  9. #9
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,477

    Re: Subtraction Formula

    Quote Originally Posted by Dowjd View Post
    Thanks bebo,

    How do I get it to display a 0?
    To get 0, it depends on values of B2 and B1: ===> B2<=B1

  10. #10
    Forum Contributor
    Join Date
    02-25-2007
    Posts
    106

    Re: Subtraction Formula

    Here is an example of my current problem:

    Cell C3 should display a 0 instead of the 76,575,490. At the bottom of the table I have it total, but it currently totals all the cells, which gives me incorrect data.


    B C
    1 0 0
    2 0 0
    3 76575490 76,575,490
    4 77333314 757,824
    5 78164163 830,849
    6 TOTAL 78,164,163

  11. #11
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,944

    Re: Subtraction Formula

    if you currently have 76,575,490 in C3, but it should read 0 instead, why not just type on 0?

  12. #12
    Forum Contributor
    Join Date
    02-25-2007
    Posts
    106

    Re: Subtraction Formula

    Would be simple, but its a monthly spreadsheet to track data and in my example if I have a 0 above a cell, it just carries the last number inputted. Which gives me incorrect data. I'd like it to not give me a total if the previous cell has no entry. if that makes sense.

  13. #13
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Subtraction Formula

    I think this has somehow gone out into left field and is way more complicated than it should be.

    This was given
    Quote Originally Posted by bebo021999 View Post
    May be:
    =IF(OR(B1="",B2=""),"",MAX(0,B2-B1))
    You responded
    Quote Originally Posted by Dowjd View Post
    Thanks bebo,

    How do I get it to display a 0?
    I would think that meant it worked, except that it returned a "" when you wanted a 0
    So I would just change
    =IF(OR(B1="",B2=""),"",MAX(0,B2-B1))
    to
    =IF(OR(B1="",B2=""),0,MAX(0,B2-B1))

  14. #14
    Forum Contributor
    Join Date
    02-25-2007
    Posts
    106

    Re: Subtraction Formula

    Thanks Jonmo1

    That worked perfectly.

    I really appreciate everyone's 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