Value_If_True Argument in IF Function Is Not Optional (179086)



The information in this article applies to:

  • Microsoft Excel 97 for Windows
  • Microsoft Excel for Windows 95
  • Microsoft Excel for Windows 5.0
  • Microsoft Excel 98 Macintosh Edition

This article was previously published under Q179086

SYMPTOMS

If you enter a formula that uses the IF worksheet function, you may receive one of the following error messages:
Error in formula.
-or-
The formula you typed contains an error.

CAUSE

This problem occurs if you completely omit the value_if_true argument in the IF worksheet function, as in the following example:

=IF(A1=0)

The Help topic for the IF worksheet function indicates that the value_if_true argument is optional; however, the argument is actually required.

RESOLUTION

To prevent this problem from occurring, make sure that you include at least a comma (,) after the logical_test argument in the IF function. For example, this formula will be accepted by Microsoft Excel:

=IF(A1=0,)

If possible, you should actually include valid value_if_true and/or value_if_false arguments, as in the following examples:
   Both arguments included
   -----------------------

   =IF(A1=0,"A1 is zero.","Al is not zero.")

   Value_if_false argument omitted
   -------------------------------

   =IF(A1=0,"A1 is zero.")

   Value_if_true argument omitted
   ------------------------------

   =IF(A1=0,,"A1 is not zero.")
				

MORE INFORMATION

In the versions of Microsoft Excel listed at the beginning of this article, the Help topic for the IF worksheet function states the following:

IF(logical_test,value_if_true,value_if_false)

Logical_test is any value or expression that can be evaluated to TRUE or FALSE.

Value_if_true is the value that is returned if logical_test is TRUE. If logical_test is TRUE and value_if_true is omitted, TRUE is returned. Value_if_true can be another formula.

Value_if_false is the value that is returned if logical_test is FALSE. If logical_test is FALSE and value_if_false is omitted, FALSE is returned. Value_if_false can be another formula.

The above information contains the following problems:

  • The second paragraph ("Value_if_true") is partially incorrect. If logical_test is TRUE and value_if_true is omitted, the IF function returns zero (0).
  • The third paragraph ("Value_if_false") is also partially incorrect. If logical_test is FALSE and value_if_false is omitted, the IF function returns zero (0).
  • If you completely omit the value_if_true argument by not including a comma after the logical_test argument, the formula will not be accepted by Microsoft Excel, and you will receive one of the error messages mentioned in the "Symptoms" section.
Note that this problem in the IF function Help topic does not occur in Microsoft Excel versions 4.0 and earlier.

Modification Type:MinorLast Reviewed:8/17/2005
Keywords:kbdocerr kbinfo KB179086