ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Sum of a cell if certain criteria are met. (https://www.excelbanter.com/excel-discussion-misc-queries/158951-sum-cell-if-certain-criteria-met.html)

Steve

Sum of a cell if certain criteria are met.
 
I know this is probably easy, but for some reason I am having a hard time
with it. Here's what I want to do.

IF A1=L THEN C1-B1
IF A1=S THEN B1-C1

Not that it matters, but L=Long, S=Short (I trade stocks) If I take a long
position, then I need to subtract the entry price from the exit price and
vice versa.

I would like the sum of that to appear in the cell I put that formula in.

Any help would be great!

Thanks again!

Sandy Mann

Sum of a cell if certain criteria are met.
 
If A1 can only hold L or S then:

=IF(A1="L",C1-B1,B1-C1)

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk


"Steve" wrote in message
...
I know this is probably easy, but for some reason I am having a hard time
with it. Here's what I want to do.

IF A1=L THEN C1-B1
IF A1=S THEN B1-C1

Not that it matters, but L=Long, S=Short (I trade stocks) If I take a
long
position, then I need to subtract the entry price from the exit price and
vice versa.

I would like the sum of that to appear in the cell I put that formula in.

Any help would be great!

Thanks again!




Farhad

Sum of a cell if certain criteria are met.
 
Hi,

Try this:

=IF(A1=L,C1-B1,IF(A1=S,B1-C1,""))

you didn't mention that what should happen if A1 would not be L or S. so i
put nothing ("").

Thanks,
--
Farhad Hodjat


"Steve" wrote:

I know this is probably easy, but for some reason I am having a hard time
with it. Here's what I want to do.

IF A1=L THEN C1-B1
IF A1=S THEN B1-C1

Not that it matters, but L=Long, S=Short (I trade stocks) If I take a long
position, then I need to subtract the entry price from the exit price and
vice versa.

I would like the sum of that to appear in the cell I put that formula in.

Any help would be great!

Thanks again!



All times are GMT +1. The time now is 12:33 PM.

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