Tuesday, June 28, 2011

If function statement

The IF function, one of Excel's logical functions, tests to see if a certain condition in a spreadsheet is true or false.


The syntax for the IF function is:

=IF ( logical_test, value_if_true, value_if_false )


logical_test - a value or expression that is tested to see if it is true or false.
value_if_true - the value that is displayed if logical_test is true.
value_if_false - the value that is displayed if logical_test is false.

Example Using Excel  IF Function:


This example will test to see if the value in cell D1 is less than 26. If it is, the IF function will place the number 50 in cell D2. If the value in D1 is not less than 20, the IF function will place the number 100 in cell D2.

  1. Enter 30 into cell D1.

  2. Click on cell E1 - the location where the results will be displayed.

  3. Click on the Formulas tab.

  4. Choose Logical Functions from the ribbon to open the drop down list.

  5. Click on IF in the list to bring up the function's dialog box.

  6. On the Logical_test line in the dialog box, click on cell D1. After this type the less than symbol ( < ) and then the number 20.

  7. On the Value_if_true line of the dialog box, type 50.

  8. On the Value_if_false line of the dialog box, type 100.

  9. Click OK.

  10. The value 100 should appear in cell E1, since the value in D1 is greater than 20.

  11. To change the result in cell E1, change the number in cell D1 to 10 and press the Enter key.

  12. The value 50 should now be present in cell E1 since the value in D1 is now less than 20.

  13. If you click on cell E1, the complete function = IF ( D1 < 20 , 50 , 100 ) appears in the formula bar above the worksheet.

No comments:

Subscribe Now: From your browser

Search:

Learn Office Excel