Help with an IF Formula

G

Guest

I am trying to put this into an excel formula:

If H1="Sell" and K1<D1 then (K1-D1)*L1*100 otherwise (D1-K1)*l1*100 OR If
H1="Buy" and K1<C1 then (K1-C1)*L1*100 otherwise (C1-K1)*L1*100

Thank you in advance.
 
G

Guest

I'm not entirely sure where the 'otherwise' statements apply relative to the
multiple IFs, but my hunch is:
=if(h1="Sell",-abs(D1-K1)*L1*100,if(h1="Buy",-abs(K1-C1)*L1*100,"Invalid
transaction type"))
--Bruce
 
G

Guest

Thank you Bruce. I've re-written my question:

If H1="Sell" and K1<D1 then (K1-D1)*L1*100 else (D1-K1)*l1*100 OR If
H1="Buy" and K1<C1 then (K1-C1)*L1*100 else (C1-K1)*L1*100

Your earlier formula did not get me the result needed. Does this make it
clearer ?

Thanks again.
 
G

Guest

Not really; I think you're confusing the OR with another level of IFs. I
think the formula does what your words say. My interpretation of your text
(with indentation to help clarify the interpretation):
IF H1=Sell THEN
IF K1<D1 THEN
(K1-D1)*L1*100 ' note this will be negative since K1<D1
ELSE
(D1-K1)*L1*100 ' likewise
END IF
ELSE
IF H1=Buy THEN
IF (K1<C1) THEN
(K1-C1)*L1*100 ' still negative; K1 < C1.
ELSE
(C1-K1)*L1*100 ' likewise
END IF
ELSE
Error
END IF
END IF
Perhaps you could provide a few examples?

--Bruce
(BTW, you should stay w/in the same thread if addressing the same issue).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top