ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Help with an IF Formula (https://www.excelbanter.com/excel-worksheet-functions/67617-help-if-formula.html)

carl

Help with an IF Formula
 
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.

bpeltzer

Help with an IF Formula
 
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

"carl" wrote:

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.


carl

Help with an IF Formula
 
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.

"bpeltzer" wrote:

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

"carl" wrote:

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.


bpeltzer

Help with an IF Formula
 
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).

"carl" wrote:

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.

"bpeltzer" wrote:

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

"carl" wrote:

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.



All times are GMT +1. The time now is 09:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com