+ Reply to Thread
Results 1 to 11 of 11

Excel 2007 : Calculating gain loss with +or- sign

  1. #1
    Registered User
    Join Date
    11-11-2011
    Location
    Otisville, Mi
    MS-Off Ver
    Excel 2007
    Posts
    21

    Calculating gain loss with +or- sign

    I am using this formula to calculate gain or loss
    How can i get a + or - sign to show in my answer.

    =IF(B3<B2,B2-B3,IF(B3>B2,B3-B2,""))

    example: + $100.00
    or - $100.00

    Any help is appreciated
    Thanks
    Joel
    Last edited by J Glanton; 11-11-2011 at 09:44 AM.

  2. #2
    Valued Forum Contributor scottylad2's Avatar
    Join Date
    09-03-2010
    Location
    edinburgh
    MS-Off Ver
    Office 2007 Prof & Office 2010 Student Edition
    Posts
    629

    Re: Calculating gain loss with +or- sign

    This will show as you wish, it becomes a Text entry though so no good for calculating., but if it's not for further calculating then it's fine

    A custom format would probably be the best answer

    =IF(B3<B2,"- "&"$"&B2-B3,IF(B3>B2,"+ "&"$"&B3-B2,""))
    Windows 7 using Office 2007 & 2010

    Remember your [ code ] [ /code ] tags, makes reading soooo much easier

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

    Re: Calculating gain loss with +or- sign

    Quote Originally Posted by J Glanton View Post
    How can i get a + or - sign to show in my answer.
    =IF(B3<B2,B2-B3,IF(B3>B2,B3-B2,""))
    Hi Joe

    if B3 > B2 then B3-B2 is always positive
    if B3 < B2 then B2-B3 is always positive

    So.. When you need your negative values?
    Never use Merged Cells in Excel

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

    Re: Calculating gain loss with +or- sign

    Also, for + or - sign you can use this custom format:

    +[$$-C09]#,##0.00;-[$$-C09]#,##0.00;[$$-C09]0;@

  5. #5
    Registered User
    Join Date
    11-11-2011
    Location
    Otisville, Mi
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Calculating gain loss with +or- sign

    Scottylad2
    Thanks
    That did what i asked for but did not allow me to format the cells as curency.
    My fault for not mentioning that.

    So what i want to do is get a cell to say the word Loss or Gain depending on the formula i am using: =IF(B2>B3,(B2-B3),B3-B2)

    I will just place this in the cell next to the information i am getting with the formula im showing above. So the left cell will have the number and the right will tell if its gain or loss.

    I have been tring to do this myself with no luck.
    Any help with this?

    Thanks again for getting involved.

  6. #6
    Registered User
    Join Date
    11-11-2011
    Location
    Otisville, Mi
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Calculating gain loss with +or- sign

    Also thanks Zbor.

  7. #7
    Registered User
    Join Date
    11-11-2011
    Location
    Otisville, Mi
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Calculating gain loss with +or- sign

    Got it
    =IF(B4<B3,("loss"),"gain")
    now if it would only make sense to me.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Calculating gain loss with +or- sign

    You have unnecessary parens:

    =IF(B4<B3, "loss", "gain")

    =IF(condition to test, value to return if true, value to return if false)

    EDIT: And this formula

    =IF(B2>B3,(B2-B3),B3-B2)

    ... could be replaced with

    =ABS(B2-B3)
    Last edited by shg; 11-11-2011 at 05:20 PM.
    Entia non sunt multiplicanda sine necessitate

  9. #9
    Registered User
    Join Date
    11-11-2011
    Location
    Otisville, Mi
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Calculating gain loss with +or- sign

    I will change those.
    Thank you very much.

    Joel

  10. #10
    Registered User
    Join Date
    11-11-2011
    Location
    Otisville, Mi
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Calculating gain loss with +or- sign

    SHG
    I hate to second guess someone who obvousiouly has a multitude of experience.
    But when i enter this =IF(B4<B3, "loss", "gain")
    I get an error. I get a FALSE in the cell
    No real concern. Just tring to learn a little while getting answers.
    The formula =IF(B3<B2,("loss"),"gain") works fine.
    Thanks Again

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Calculating gain loss with +or- sign

    You're referencing different cells with those two formulas, but irrespective, that formula should never return FALSE. Can you post a workbook with an example of that?

+ 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