+ Reply to Thread
Results 1 to 4 of 4

Test two cells and set a third cell with different values depending on test results

  1. #1
    Registered User
    Join Date
    08-21-2013
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2007
    Posts
    2

    Test two cells and set a third cell with different values depending on test results

    I am a beginner in Excel, and I am trying to determine Long Term Gain (LTG,) Long Term Loss (LTL,) Short Term Gain (STG,) Short term Loss (STL,) or No Loss nor Gain (NGL)testing two cells (A1 and B1)and setting a third cell (C1) to the text LTG, LTL, STG, STL, or NGL depending on the results of testing cells A1 and B1.
    A1 represent a number of years and B1 represent gains or losses (negative)in dolars.

    The way I see the logic is as follows:
    If cell A1 or cell B1 are either one of them equal to 0, then it is neither a Gain nor a Loss (NGL.)
    If cell A1 is greater than or equal to 1, then it is Long Term; else, if A1 is greater than 0 and less than 1, then it is Short Term.

    On the other hand, if cell B1 is greater than 0, then it is a Gain; if B1 is less than 0 (a negative number,) then, it is a Loss.

    I need to find (if it is posible in Excel) one formula to test the two cells for posible outcomes:
    If A1 = 0 then C1 = NGL
    If B1 = 0 then C1 = NGL
    If A1 >= 1 and B1 > 0 the C1 = LTG.
    If A1 >= 1 and B1 < 0 the C1 = LTL.
    If A1 < 1 and B1 > 0 then C1 = STG
    If A1 < 1 and B1 < 0 then C1 = STL

    I can't figure it out if it can be done or how to do it in Excel; I have tried reading about with IF, AND, OR, nested and otherwise, but cannot figure out the formula. Can anyone help?; I would be very grateful.

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Test two cells and set a third cell with different values depending on test results

    This might work. I'm not near a computer right now to try it out.

    Formula: copy to clipboard
    Please Login or Register  to view this content.

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

    Re: Test two cells and set a third cell with different values depending on test results

    you need to put the IF(OR(A1=0,B1=0) further along the logic else if a1=0 and b1 >0 the IF(AND(A1 < 1, B1 > 0),"STG" would not be considered
    =IF(AND(A1<1,B1<0),"STL",IF(AND(A1>=1,B1>0),"LTG",IF(AND(A1>=1,B1<0),"LTL",IF(AND(A1<1,B1>0),"STG",IF(OR(A1=0,B1=0),"NGL")))))
    "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

  4. #4
    Registered User
    Join Date
    08-21-2013
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Test two cells and set a third cell with different values depending on test results

    Quote Originally Posted by martindwilson View Post
    you need to put the IF(OR(A1=0,B1=0) further along the logic else if a1=0 and b1 >0 the IF(AND(A1 < 1, B1 > 0),"STG" would not be considered
    =IF(AND(A1<1,B1<0),"STL",IF(AND(A1>=1,B1>0),"LTG",IF(AND(A1>=1,B1<0),"LTL",IF(AND(A1<1,B1>0),"STG",IF(OR(A1=0,B1=0),"NGL")))))
    It worked!!; perfect!1
    I will study it to learn for next time; I will try to turn the outcomes 9text0 with different colors.
    Thanks a lot to you and also to Daffodil.

+ 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. [SOLVED] Test if a cell is within a name range and return a text value based on the test
    By DraconR in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 06-24-2013, 02:46 AM
  2. Pull sub-test scores from test w/best overall test score (PSAT)
    By PowerSchoolDude in forum Excel General
    Replies: 0
    Last Post: 11-19-2009, 08:29 PM

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