+ Reply to Thread
Results 1 to 3 of 3

How do I write a positive/negative and red/green function?

  1. #1
    Registered User
    Join Date
    05-18-2009
    Location
    new jersey, united states
    MS-Off Ver
    Excel 2003
    Posts
    12

    How do I write a positive/negative and red/green function?

    I'm trying to make a "weight-based" spreadsheet. I want to show a difference between numbers so if an item lost 5 lbs, there would be a "-5" and it would be in green font showing good.

    For example, a box weighs 20 lbs and then drops down to 15 lbs. This would be a good result. So I would have 20 lbs in A4 and 15 lbs in A6 and I want to show the difference in A8. However, since I want the box to lose weight, I want it to show a negative value of "-5" in green font meaning it is good. And vice versa, I want it to show "+3" in red font if the box gained weight.

    I can't really figure out how to get the signs working properly. I'm assuming to use an "if" function in where if the difference is a loss, show the negative sign and have it in green font. And if the difference is a gain, show the positive sign in red font.


    I hope this wasn't confusing.
    Last edited by indolence; 05-19-2009 at 03:13 PM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434

    Re: How do I write a positive/negative and red/green function?

    Formula in A8 would be

    =A6-A4

    One way to get the font colour is to use a custom number format for A8

    [Red]"+"General;[Green]-General;General

    Alternatively you can use Condition formatting. Testing for a value Less Than 0.
    Use formatting of Font-Green.

    If you want 0 in black then add another condition for Greater than 0.
    Otherwise format the cell as having Red font
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    03-27-2009
    Location
    Surat,India
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: How do I write a positive/negative and red/green function?

    Do it using Conditional Formating

    Find Attached file.

    Vishnu
    Attached Files Attached Files

+ 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