# certain words in a cell determine which column is meant?

1. ## certain words in a cell determine which column is meant?

Hi everyone,

I want to do a very simple calculation like (x-y)*z, but I've 2 different columns for which could be "y". so I want to make 2 keywords determining which column the calculation should consider.

I've also tried to explain it in my xlm file.

Thanks.

2. ## Re: certain words in a cell determine which column is meant?

In H2 and copy down =IF(G2="TP",(C2-B2)*F2,(D2-B2)*F2)

3. ## Re: certain words in a cell determine which column is meant?

does this formula do what you need

=IF(G2="TP",SUM(C2-B2)*F2,IF(G2="SL",SUM(D2-B2)*F2,""))

4. ## Re: certain words in a cell determine which column is meant?

Wow, that was fast.

Thank you very much, helped a lot.

5. ## Re: certain words in a cell determine which column is meant?

you are welcome

6. ## Re: certain words in a cell determine which column is meant?

I've got one more question, I'm sure these are probably pretty easy formulas but I tried for hours and couldn't get it done.

What if there is one more cell with 2 different words which determines what way it should be calculated with all that formula included from before. Is that possible?

I attached an example file again so it's easier to understand what I want to ask.

7. ## Re: certain words in a cell determine which column is meant?

You can use an AND() to determing what happens

SO
AND( A2 = "L", G2= "SL" )
for each combination in a nested IF

IF ( AND( A2 = "L", G2= "SL" ) , Calc1, IF ( AND( A2 = "L", G2= "TP" ) , Calc2, IF ( AND( A2 = "S", G2= "SL" ) , Calc3, IF ( AND( A2 = "S", G2= "TP" ) , Calc4, "" ))))

what do you want to do for all 4 possible combinations
A2 = "L", G2= "SL"
A2 = "L", G2= "TP"
A2 = "S", G2= "SL"
A2 = "S", G2= "TP"

Also will
Column A ever be blank, and a Calc needed ?
Column G ever be blank, and a Calc needed ?

8. ## Re: certain words in a cell determine which column is meant?

I try to do a trading journal so I can keep up with my trades, and for a very long time I did all that manually but that costs me to much time.
Column A and G will always filled in manually, and they never will be blank.

9. ## Re: certain words in a cell determine which column is meant?

OK, so the formula I suggested will work
maybe ADD the calculation you need for the 4 options , even if the same

A2 = "L", G2= "SL" = CALC 1 ?
A2 = "L", G2= "TP" = CALC 2 ?
A2 = "S", G2= "SL" = CALC 3 ?
A2 = "S", G2= "TP" = CALC 4 ?

10. ## Re: certain words in a cell determine which column is meant?

thank you very much again, took me a while until I managed to enter the whole formula without any mistakes hahaha, but it works perfectly. Now I'm happy and satisfied

11. ## Re: certain words in a cell determine which column is meant?

Ok, IF you have the same formula , then you can reduce the Nesting by using an OR or {}

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1