+ Reply to Thread
Results 1 to 4 of 4

Combining Two Formulas

  1. #1
    Registered User
    Join Date
    05-28-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    12

    Combining Two Formulas

    Hi All,

    For some reason unknown to me; I cannot combine these two formulas below.
    Every time I get a result for BUY Stop and BUY Limit it shows a number but the SELL Limit and SELL Stops show "FALSE" and do not calculate.

    Full Formula:

    =IF(E2="BUY",IF(F2="Stop",((G2-K2)/K2),(IF(E2="BUY",IF(F2="Limit",(-(G2-K2)/K2)),IF(E2="SELL",IF(F2="Stop",(-(G2-K2)/K2),(IF(E2="SELL",IF(F2="Limit",((G2-K2)/K2)),"ERROR"),"ERROR"),"ERROR"),"ERROR"),"ERROR"),"ERROR"),"ERROR"),"ERROR")

    Individual Formulas to create the full formula (these work individually):

    =IF(E2="BUY",IF(F2="Stop",((G2-K2)/K2),(IF(E2="BUY",IF(F2="Limit",(-(G2-K2)/K2)),"ERROR"))))
    =IF(E2="SELL",IF(F2="Stop",(-(G2-K2)/K2),(IF(E2="SELL",IF(F2="Limit",((G2-K2)/K2)),"ERROR"))))

    Cheers.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: Combining Two Formulas

    maybe this:

    =IF(ISERR(1/K2),"Error",IF(E2="Buy",1,-1)*IF(F2="Limit",-1,1)*(G2-K2)/K2)

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

    Re: Combining Two Formulas

    Upper solution consider that if it's not BUY then it's SELL... Also, if it's not LIMIT then it's STOP.
    But if you want to consider all 4 solutions (there can be other words in cells and you need to return ERROR) then you can do something like:

    =IFERROR(SIGN(MATCH(E2&F2,{"BuyLimit","SellStop","BuyStop","SellLimit"},0)-2,5)*(G2-K2)/K2,"ERROR")

  4. #4
    Registered User
    Join Date
    05-28-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Combining Two Formulas

    Hi there. I don't believe this works. I think you've got a comma in the wrong place where the "5" is.

+ 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