Help tweaking a formula

S

Shhhh

Hello all I have a spreadsheet where I am calculating returns from certain
stock trades, here is the formula I have so far which I have in great part
due to help from the kind folks on this board...

=IF(ISERROR((((F7-E7)*(100000*D7))/H7)+G7),"",(((F7-E7)*(100000*D7))/H7)+G7)

The problem I'm experiencing now is differentiating between long trades and
short trades, Column "A" has either buy or sell in it... is there a way I
can specify Excel to keep this formula but look at column "A" and
if A = buy then F7-E7 ... but ...
if A = sell then E7-F7

all the rest of the formula remains the same...

All help greatly appreciated,
Shhhh
 
D

Dave Peterson

maybe...

=IF(ISERROR((((IF(A1="buy",F7-E7,E7-F7))*(100000*D7))/H7)+G7),"",
(((IF(A1="buy",F7-E7,E7-F7))*(100000*D7))/H7)+G7)

Actually, this says if "buy" do it this way--otherwise (no matter what), do it
the other way.

You may want to look at what causes the error. If you're worried about dividing
by 0, you may be able to just check H7.

=if(h7=0,"",rest of formula)
 

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