+ Reply to Thread
Results 1 to 5 of 5

How to recognise negative numbers in a formula?

  1. #1
    Registered User
    Join Date
    10-08-2013
    Location
    Wales
    MS-Off Ver
    Excel 2010 Mac
    Posts
    2

    How to recognise negative numbers in a formula?

    I wish to calculate the difference between two test scores and then assign a letter value based on the difference in the scores. The formula I have tried to use is:

    =IF(OR($P4="", $Q4="", $R4=""),"",IF(R4>=4,"W",IF(R4>=0,"X",IF(R4<0,"Y",IF(R4<=-5,"Z",)))))

    P is 1st test result. Q is 2nd test result. R is the difference in test scores (the result is sometimes negative).

    'W', 'X' and 'Y' all display when appropriate, but I can't get the formula to display 'Z' for any test result. It should do so when the result is negative 5 or 'less'. Can excel recognise negative numbers in a formula of this type? If not, what functions can I use to display the letters appropriately?

    Thanks for your help.

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: How to recognise negative numbers in a formula?

    Try this.

    =IF(OR($P4="", $Q4="", $R4=""),"",IF(R4>=4,"W",IF(R4>=0,"X",IF(R4>-5,"Y","Z"))))
    Last edited by sktneer; 10-08-2013 at 09:07 PM.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: How to recognise negative numbers in a formula?

    welcome to the forum grrr34. that's because the IF formula test for each condition from left to right & stops when the condition is TRUE. so anything less than 0 is already ends here before you test for "Z":
    IF(R4<0,"Y"

    you should keep your conditions consistently going up or down. since you're testing for >=, keep it that way.
    =IF(OR($P4="", $Q4="", $R4=""),"",IF(R4>=4,"W",IF(R4>=0,"X",IF(R4>-5,"Y",IF(R4<=-5,"Z",)))))

    and since there will be no other results possible when it's not "", >=4, >=0, >-5, it can only be <=-5. there is no need to test for that:
    =IF(OR($P4="", $Q4="", $R4=""),"",IF(R4>=4,"W",IF(R4>=0,"X",IF(R4>-5,"Y","Z"))))

    you can also reduce it further by counting if P4:R4 is 3 counts (meaning 3 numbers):
    =IF(COUNT(P4:R4)<>3,"",IF(R4>=4,"W",IF(R4>=0,"X",IF(R4>-5,"Y","Z"))))

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  4. #4
    Registered User
    Join Date
    10-08-2013
    Location
    Wales
    MS-Off Ver
    Excel 2010 Mac
    Posts
    2

    Re: How to recognise negative numbers in a formula?

    Brill! Thank you for the extra info and the kind welcome.

    I have another problem this evening:

    I would like to paste multiple cells with their formulas from one workbook to another. The formulas refer to a different sheet within the workbook, and when I paste special - formula, the actual sheet name from the first workbook is pasted also. I don't want this to happen as the I want it to refer to a sheet with the same name in the second workbook (and not back to the first workbook). I hope this is clear. I can provide extra info if not.

    Is there another paste option which will paste the formulas, but not the reference to the sheet in the first workbook?
    Last edited by grrr34; 10-09-2013 at 07:10 PM.

  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,939

    Re: How to recognise negative numbers in a formula?

    To add to Bens comment of...
    you can also reduce it further by counting if P4:R4 is 3 counts (meaning 3 numbers):
    =IF(COUNT(P4:R4)<>3,"",IF(R4>=4,"W",IF(R4>=0,"X",IF(R4>-5,"Y","Z"))))
    If R is the difference between P and Q, , I would think you only need to test R, so you can reduce it further to...
    =IF(R4="","",IF(R4>=4,"W",IF(R4>=0,"X",IF(R4>-5,"Y","Z"))))

    Also, if your post #4 is a different question, please start another thread with that question

    Thanks
    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

+ 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. Replies: 5
    Last Post: 05-12-2009, 04:47 PM
  2. Getting Count field to recognise rows with negative values in Exc.
    By hamish in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 04:05 AM
  3. Getting Count field to recognise rows with negative values in Exc.
    By hamish in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-20-2005, 01:05 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