Computer Science, asked by amansrivastava2005, 8 months ago

Accept a value in cell Al and check it is
a number or string​

Answers

Answered by mobilebackup222
1

Explanation:

Got it!

Using IF function in Excel: formulas for numbers, text, dates, blank cells

by Svetlana Cheusheva | updated on September 9, 2020 3,812 Comments

IF is one of the most popular and useful functions in Excel. You use an IF statement to test a condition and to return one value if the condition is met, and another value if the condition is not met.

In this tutorial, we are going to learn the syntax and common usages of Excel IF function, and then will have a closer look at formula examples that will hopefully prove helpful both to beginners and experienced users.

Excel IF function - syntax and usage

Using the IF function in Excel - formula examples

IF examples for numbers

How to use the IF function with text values

Using IF function with dates

Excel IF statement for blank, non-blank cells

Excel IF function - syntax and usage

The IF function is one of logical functions that evaluates a certain condition and returns the value you specify if the condition is TRUE, and another value if the condition is FALSE.

The syntax for IF is as follows:

IF(logical_test, [value_if_true], [value_if_false])

As you see, the IF function has 3 arguments, but only the first one is obligatory, the other two are optional.

logical_test (required) - a value or logical expression that can be either TRUE or FALSE. In this argument, you can specify a text value, date, number, or any comparison operator.

For example, your logical test can be expressed as or B1="sold", B1<12/1/2014, B1=10 or B1>10.

value_if_true (optional) - the value to return when the logical test evaluates to TRUE, i.e. if the condition is met.

For example, the following formula will return the text "Good" if a value in cell B1 is greater than 10: =IF(B1>10, "Good")

value_if_false (optional) - the value to be returned if the logical test evaluates to FALSE, i.e. if the condition is not met.

For example, if you add "Bad" as the third parameter to the above formula, it will return the text "Good" if a value in cell B1 is greater than 10, otherwise, it will return "Bad": =IF(B1>10, "Good", "Bad")

Excel IF function - formula example

IF function - things to remember!

Though the last two parameters of the IF function are optional, your formula may produce unexpected results if you don't know the underlying logic beneath the hood.

If value_if_true is omitted

If the value_if_true argument is omitted (i.e. there is only a comma following logical_test), the IF function returns zero (0) when the condition is met. Here is an example of such a formula:

=IF(B1>10,, "Bad")

In case you don't want your Excel IF statement to display any value when the condition is met, enter double quotes ("") in the second parameter, like this: =IF(B1>10, "", "Bad"). Technically, in this case the formula returns an empty string, which is invisible to the user but perceivable to other functions.

The following screenshot demonstrates the above approaches in action, and the second one seems to be more sensible:

IF formulas with the value_if_true argument omitted

If value_if_false is omitted

If you don't care what happens when the specified condition is not met, you can omit the 3rd parameter in your formulas, which will result in the following.

If the logical test evaluates to FALSE and the value_if_false parameter is omitted (there is just a closing bracket after the value_if_true argument), the IF function returns the logical value FALSE. It's a bit unexpected, isn't it? Here is an example of such a formula: =IF(B1>10, "Good")

Putting a comma after the value_if_true argument forces your IF statement to return 0, which doesn't make much sense either: =IF(B1>10, "Good",)

And again, the most reasonable approach is to put "" in the third argument, in this case you will have empty cells when the condition is not met: =IF(B1>10, "Good", "")

IF formulas with the value_if_false argument omitted

Get the IF function to display logical values TRUE or FALSE

For your Excel IF formula to display the logical values TRUE and FALSE when the specified condition is met and not met, respectively, type TRUE in the value_if_true argument. The value_if_false parameter can be FALSE or omitted. Here's a formula example:

=IF(B1>10, TRUE, FALSE)

or

=IF(B1>10, TRUE)

an example of the IF function that displays logical values TRUE or FALSE

Note. For your IF statement to return TRUE and FALSE as the logical values (Boolean values) that other formulas can recognize, make sure you don't enclose them in double quotes. A visual indication of a Boolean is middle align in a cell, as you see in the screenshot above.

If you want "TRUE" and "FALSE" to be usual text values, enclose them in "double quotes". In this case, the returned values will be aligned left and formatted as General. No Excel formula will recognize such "TRUE" and "FALSE" text as logical values.

Similar questions