# Excel - Linking if-and-or statements

April 23, 2009 at 19:12:47
Specs: Windows Vista
 I'm trying to link this together - if E10>F10,then E10-F10 if true, and F10-E10 if false; but if Cell C10 has the word "Sell" and E10

See More: Excel - Linking if-and-or statements

#1
April 23, 2009 at 19:22:08
 Try this:=IF(C10="sell",IF(E10F10,E10-F10,F10-E10))MIKEhttp://www.skeptic.com/

Report •

#2
April 24, 2009 at 19:35:52
 Mike - Thanks for formula - I plugged it in, but it returns a positive number when is should be negative and a positive number when it should be positive.Here is the data when the result is positive and should be so -E5 = 0.8691F5 = 0.8651P5 = Sell*10000 to produce a 2 digit value in G5 the cell I have the formula inside.Formula =IF(P5="Sell",IF(E5>F5,E5-F5,0),IF(E5F6,E6-F6,0),IF(E6

Report •

#3
April 24, 2009 at 21:28:51
 Let's go back to your original post and see if we can break it down to make it easier to understand.if E10>F10,then E10-F10 if true, and F10-E10 if falseWhich can be written as follows:=IF(E10>F10,E10-F10,F10-E10)if Cell C10 has the word "Sell" and E10F10? That doesn't seem to be covered anywhere.I guess what I'm trying to say here is that I'm not sure you've stated your criteria in a manner that allows us the write a formula that meets your needs.

Report •

Related Solutions

#4
April 24, 2009 at 22:55:03
 I'm sorry for the confusion. I am tracking the gain/loss on Buying and Short Selling Currency Pairs. When a pair is 'bought' (Buy), the math is pretty simple, Exit Price - Entry Price = P/L. But with a Short Sell (listed on spread sheet as "Sell"), it needs to reflect Entry Price - Exit Price = P/L.Column E holds the Entry Price, Column F holds the Exit Price, and Column P holds the word "Buy" or "Sell" depending on the type. The calculation for P/L is in Column G. I add either *100 (JPY base pair) or *10000 (non-JPY base pair) to have the result display in a whole number.I thought I would need to include whether the Entry Price was > or < the Exit Price, but maybe that isn't necessary.The 4 possible scenarios I need to account for in a single repeatable formula are:"Buy" (win) EntryExit.....Exit-Entry= Result negative"Sell" (win) Entry>Exit.....Entry-Exit= Result positive"Sell" (loss) Entry

Report •

#5
April 25, 2009 at 18:24:33
 I put this in G2 and dragged it down to G5 to get these results. They appear to match the criteria in your most recent post. The assumption is that Column P will always contain either Buy or Sell.=IF(P2="Buy",F2-E2,E2-F2)``` E F G P 1 Entry Exit EntryExit.....Exit-Entry: 3 5 4 -1 Buy Entry>Exit.....Entry-Exit: 4 5 4 1 Sell Entry

Report •