Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to use the function IF() from Excel in a formula for some Cell, as shown below -

=IF(I2="SELL","(C2-F2)*D2","0")

Which means I want to see if Cell I2 has text- SELL in it (IF condition true), then I want the cell to have formula as (C2-F2)*D2, else if condition is false, it prints 0.

But trouble is that when condition is true, instead of putting the formula for the text it is putting the string (C2-F2)*D2 as it is in that Cell. What I want is that when condition is true, it should interpret (C2-F2)*D3 as formula in that cell. I tried many things , like -

=IF(I2="SELL","=((C2-F2)*D2)","0") 

or

=IF(I2="SELL","=("(C2-F2)*D2)"","0") 

but without any success.

share|improve this question
    
Putting "" around "(C2-F2)*D2" changed it from a formula into a string. –  bitslave Nov 25 '10 at 14:42
add comment

2 Answers

up vote 6 down vote accepted

=IF(I2="SELL",(C2-F2)*D2,0) will put the required calculated values in the cell. The formula is the complete one with the IF

As said by others = "..." just gives the string between the "" and Excel will not try to evaluate it.

share|improve this answer
    
Thank you, it works. –  goldenmean Nov 25 '10 at 14:45
    
In excel quotation marks return the text between them rather than the results of the equation. This can be useful if you want to return a "Yes" from an IF statement, or as you have done use a "Sell" in the logical statement. –  markfknight Jun 5 '11 at 10:34
add comment

"" will just paste a string.

Just use =IF(I2="SELL";(C2-F2)*D2;0)

share|improve this answer
    
May be typo , but it should not have semicolons, but commas as separators. –  goldenmean Nov 25 '10 at 14:50
2  
Sorry, that's just that I use the Spanish version of MS Office –  molgar Nov 25 '10 at 14:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.