Excel if cell is true

IF function

The IF function is one of the most popular functions in Excel, and it allows you to make logical comparisons between a value and what you expect.

So an IF statement can have two results. The first result is if your comparison is True, the second if your comparison is False.

For example, =IF(C2=”Yes”,1,2) says IF(C2 = Yes, then return a 1, otherwise return a 2).

Your browser does not support video. Install Microsoft Silverlight, Adobe Flash Player, or Internet Explorer 9.

Use the IF function, one of the logical functions, to return one value if a condition is true and another value if it’s false.

IF(logical_test, value_if_true, [value_if_false])

For example:

  • =IF(A2>B2,»Over Budget»,»OK»)

  • =IF(A2=B2,B4-A4,»»)

Argument name

Description

logical_test    (required)

The condition you want to test.

value_if_true    (required)

The value that you want returned if the result of logical_test is TRUE.

value_if_false    (optional)

The value that you want returned if the result of logical_test is FALSE.

Simple IF examples

Cell D2 contains a formula =IF(C2="Yes",1,2)

  • =IF(C2=”Yes”,1,2)

In the above example, cell D2 says: IF(C2 = Yes, then return a 1, otherwise return a 2)

Cell D2 contains the formula =IF(C2=1,"YES","NO")

  • =IF(C2=1,”Yes”,”No”)

In this example, the formula in cell D2 says: IF(C2 = 1, then return Yes, otherwise return No)As you see, the IF function can be used to evaluate both text and values. It can also be used to evaluate errors. You are not limited to only checking if one thing is equal to another and returning a single result, you can also use mathematical operators and perform additional calculations depending on your criteria. You can also nest multiple IF functions together in order to perform multiple comparisons.

Formula in cell D2 is =IF(C2>B2,”Over Budget”,”Within Budget”)

  • =IF(C2>B2,”Over Budget”,”Within Budget”)

In the above example, the IF function in D2 is saying IF(C2 Is Greater Than B2, then return “Over Budget”, otherwise return “Within Budget”)

Formula in cell E2 is =IF(C2>B2,C2-B2,"")

  • =IF(C2>B2,C2-B2,0)

In the above illustration, instead of returning a text result, we are going to return a mathematical calculation. So the formula in E2 is saying IF(Actual is Greater than Budgeted, then Subtract the Budgeted amount from the Actual amount, otherwise return nothing).

Formula in Cell F7 is IF(E7=”Yes”,F5*0.0825,0)

  • =IF(E7=”Yes”,F5*0.0825,0)

In this example, the formula in F7 is saying IF(E7 = “Yes”, then calculate the Total Amount in F5 * 8.25%, otherwise no Sales Tax is due so return 0)

Note: If you are going to use text in formulas, you need to wrap the text in quotes (e.g. “Text”). The only exception to that is using TRUE or FALSE, which Excel automatically understands.

Common problems

Problem

What went wrong

0 (zero) in cell

There was no argument for either value_if_true or value_if_False arguments. To see the right value returned, add argument text to the two arguments, or add TRUE or FALSE to the argument.

#NAME? in cell

This usually means that the formula is misspelled.

Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

Connect with an expert. Learn from live instructors.

See Also

IF function — nested formulas and avoiding pitfalls

IFS function

Using IF with AND, OR and NOT functions

COUNTIF function

How to avoid broken formulas

Overview of formulas in Excel

Need more help?

Skip to content

How to Use the IF Function in Excel: Step-by-Step (2023)

How to Use the IF Function in Excel: Step-by-Step (2023)

The IF function is going to be one of the most useful functions of Excel you’ll ever come across🤩

Once you know how to write the IF function, you’ll use it almost everywhere. With the IF function, Excel tests a given condition.

And returns one value if the condition turns true and another if it turns false. More details about the IF function with many examples of the same await you in the guide below 👇

So jump straight in and take our free sample workbook along with you to practice better.

How to use the IF function in Excel

The IF function is a logical function of Excel that’ll test a supplied condition. If the condition is true, the IF function would return one value.

And if it is false, it will return another value. And by the way, both these values will be supplied by you. Let’s see this through an example 👩‍🏫

Here we have a list of some people along with their ages.

List of people and their ages

Can we use the IF function to see which of these are of the age of 50? For sure. See here:

  1. Activate a cell.
  2. Write the IF function as below:

= IF (B2=50,

Writing the IF function

For the first argument of the IF function, write in the condition to be tested 👴

We want to test if the age of each person equals 50. Ages are in column B so we have written the logical condition B2=50.

This tells Excel to test if B2 is equal to 50.

Note that we have used a logical operator (=) to specify the condition. You’d need a logical operator to specify any kind of condition.

Kasper Langmann, Microsoft Office Specialist
  1. As the next argument, write the value_if_true as below:

= IF (B2=50, “Equals 50”,

Writing the value_if_true

The value_if_true is the value that Excel would return if the logical condition turned true. It is an optional argument that you can omit ❌

For now, we are setting it to “Equals 50”.

If the value_if_true is omitted, and the logical test turns true, Excel simply returns the Boolean value “TRUE” in its place.

Kasper Langmann, Microsoft Office Specialist
  1. Next, write in the value_if_false as below:

= IF (B2=50, “Equals 50”, “Doesn’t equal 50”)

Writing the value_if_false

The value_if_false is the value that Excel would return if the logical condition turned false. It is also an optional argument that you can omit.

We have set it to ‘Doesn’t Equal 50” 🙈

Do not forget to enclose the value_if_true and value_if_false in double quotation marks. Or else would fail to recognize it as a text.

And your IF function would return the #NAME error 🤯

If the value_if_false is omitted, Excel simply returns the Boolean value “FALSE” in its place.

Kasper Langmann, Microsoft Office Specialist
  1. All good! Hit Enter.
IF function formula returns the results

The IF function evaluates if Cell B2 is equal to 50. And as that’s not the case, we get “Doesn’t equal 50” (the value_if_false) 🚩

  1. Drag and drop the same formula to the whole list.
Formula applied to the whole list

And there you get the results of the IF function for the entire list🥂

Note how Excel has supplied the value if true (Equals 50) for Cell B3 and B6 where the age is 60. Pretty simple that was!

IF and logical operators

You can take the IF function game levels ahead by using it together with logical operators.

For example, using the same dataset as above, can we readily see which people are above 50 👀

  1. Write the IF function as below:

= IF (B2>50,

The logical condition for the IF function

As we want to find the ages that are greater than 50, we are going to define a logical condition using the greater than (>) logical operator.

So we have written the condition as B2>50 (is B2 greater than 50?).

  1. Then write the value_if_true and value_if_false as below:

= IF (B2>50, “Greater than 50”, “Not greater than 50”)

Writing the true and false values

We want Excel to return the text string “Greater than 50” if the age is more than 50.

And if any age is less than 50, we want Excel to return “Not greater than 50” ✈

  1. Press Enter.
IF function returns the results

The IF function evaluates if Cell B2 is greater than 50. And we get the result “Greater than 50” in the very first cell as the age in Cell B2 is 88. (88>50) 👌

  1. Drag and drop the same formula to the whole list.
Formula applied to the whole list

Excel evaluates the whole list, and we have our results ready. You can use logical operators like that to test any logical condition.

Pro Tip!

You can use a total of 6 logical operators to write any logical test in Excel 6️⃣

  • Equal to (=)
  • Greater than (>)
  • Less than (<)
  • Greater than or equal to (>=)
  • Less than or equal to (<=)
  • Not equal to (<>)

Other IF formula examples

We’ve yet not had enough of the IF function – and there’s much more to come. Let’s see some more examples of the IF function below 🚴‍♀️

IF formula example #1

The above two examples show how you can use the IF function with numbers. But what if you want to use it with text?

You can still do that. Look into the data below.

Status of Employee duties

Some employees worked overtime, whereas others did not. Based on the overtime detail, we need to offer incentives to employees 💰

So can we readily see which employees are getting a bonus this time?

  1. Write the IF function as below:

= IF (B2=”Worked Overtime”

Text as the logical condition

As we want to find which employee did overtime, we defined the logical condition B2=” Worked Overtime”.

This way Excel will see if cell B2 contains the text value “Worked Overtime” or not.

Here’s something for you to take note of. As we have specified text in our logical condition this time, we have enclosed it in double quotation marks.

Excel would fail to test a text logical condition if the text portion is not enclosed in quotation marks 📌

Kasper Langmann, Microsoft Office Specialist
  1. Then write the value_if_true and value_in_false as below:

= IF (B2=”Worked Overtime”, “Yes”, “No”)

Writing the true and false values

For any employee who has worked overtime, Excel will return a “Yes” and vice versa.

  1. Hit Enter to run the function 🏃‍♀️
IF function runs the logical test
  1. Drag and drop the same formula to the whole list.
IF statement applied to the whole list

The IF function tests if the cells have the text value “Worked Overtime”. And for all the cells that have this value, the result is a “Yes”. And for the employees who didn’t work overtime, the result is a “No”.

Pro Tip!

Did you note that Cell B5 has the status “WORKED OVERTIME” (uppercase characters)?

However, the IF function still finds the logical test to be true, and we have the value “Yes”.

This tells that the IF function is not case-sensitive 🏆

IF formula example #2

This example is going to be an interesting one. We are going to use the IF function with dates in logical tests.

The image below shows different events scheduled on certain dates 📅

In addition to these events, there is another event planned for 03 March 2023. We will now use the IF function to see if any event clashes with the event on 03 March.

  1. Write the IF function as below:

= IF (B2=DATE(2023,03,03)

as the logical condition

We have written the logical test as B2=DATE(2023,03,03)

Excel would now test if cell B2 contains the date 03-Mar-2022 or not.

Pro Tip!

To write the logical criterion using date, we have used the DATE function that works as follows:

=DATE(year,mm,dd)

It is important to know that the logical functions of Excel cannot recognize dates. They instead consider them as text strings 😅

To use dates in the IF function, you must use the DATE function for Excel to convert the date into an understandable format.

Alternatively, you can convert the date into a serial number and then write the IF function like this:

= IF (B2=44988,

However, to know the serial number for the targeted date (like 44988 for 03 March 2023), you still need to apply the DATE function separately 🤷‍♀️

  1. Then write the value_if_true and value_if_false as below:

= IF (B2=DATE(2023,03,03), “Yes”, “No”)

Writing the true and false values

For events that are scheduled on 03 March 2022, Excel will return a “Yes”.

And if that’s not the case, we will get a clean “No” ❌

Interesting, right? Let’s now run the function to see the final results.

  1. Hit Enter.
IF function evaluates the corresponding value
  1. Drag and drop the same formula to the whole list.
IF formula returns the results

Seems like we would have to miss out on Event 3 and Event 5 🙅‍♂️

That’s it – Now what?

A long way we’ve come. In the guide above, we have seen how to use the basic IF function, IF function with logical operators, and with single and multiple conditions.

With this, you now know all the ins and outs of the IF function of Excel. I hope you enjoyed reading it as much as I enjoyed writing it ✍

If you found the IF function useful, must know that it only makes one function of the great Excel. This giant spreadsheet software has so much more for you to explore.

To become an Excel maestro, you must have a fine grip on Excel functions. Particularly, the key Excel functions like the VLOOKUP, SUMIF, and IF functions.

Don’t know where to start? Enroll in my 30-minute free email course that will take you through these (and many more) functions of Excel.

Frequently asked questions

IF is a logical function of Excel. It tests a given condition to be logically true or false.

It allows users to specify a value to be returned if the supplied condition is true, and a value if it is false.

The IF function then evaluates the condition and returns the relevant value if it proves true or false.

The Excel IF function has the following three articles:

Logical_test (required argument) – this is the logical test to be performed.

Value_if_true (optional argument) – this is the value to be returned if the logical test is true.

Value_if_false (optional argument) – this is the value to be returned if the logical test is false.

The IF function can be used to test more complex scenarios by nesting multiple IF functions together.

For example, you can nest multiple IF functions together as follows:

 = IF (logical_condition, [value_if_true], IF (logical_condition, [value_if_true], [value_if_false])

This tells Excel to test the first IF function and return the value_if_true if it is true. And if it is false, test the second (nested) IF function.

To learn this in much more detail (with a handful of examples), read our tutorial on the Nested IF function here!

Kasper Langmann2023-02-23T14:47:57+00:00

Page load link

The IF function runs a logical test and returns one value for a TRUE result, and another value for a FALSE result. The result from IF can be a value, a cell reference, or even another formula. By combining the IF function with other logical functions like AND and OR, you can test more than one condition at a time.

Syntax

The generic syntax for the IF function looks like this:

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

The first argument, logical_test, is typically an expression that returns either TRUE or FALSE. The second argument, value_if_true, is the value to return when logical_test is TRUE. The last argument, value_if_false, is the value to return when logical_test is FALSE. Both value_if_true and value_if_false are optional, but you must provide one or the other. For example, if cell A1 contains 80, then:

=IF(A1>75,TRUE) // returns TRUE
=IF(A1>75,"OK") // returns "OK"
=IF(A1>85,"OK") // returns FALSE
=IF(A1>75,10,0) // returns 10
=IF(A1>85,10,0) // returns 0
=IF(A1>75,"Yes","No") // returns "Yes"
=IF(A1>85,"Yes","No") // returns "No"

Notice that text values like «OK», «Yes», «No», etc. must be enclosed in double quotes («»). However, numeric values should not be enclosed in quotes.

Logical tests

The IF function supports logical operators (>,<,<>,=) when creating logical tests. Most commonly, the logical_test in IF is a complete logical expression that will evaluate to TRUE or FALSE. The table below shows some common examples:

Goal Logical test
If A1 is greater than 75 A1>75
If A1 equals 100 A1=100
If A1 is less than or equal to 100 A1<=100
If A1 equals «Red» A1=»red»
If A1 is not equal to «Red» A1<>»red»
If A1 is less than B1 A1<B1
If A1 is empty A1=»»
If A1 is not empty A1<>»»
If A1 is less than current date A1<TODAY()

Notice text values must be enclosed in double quotes («»), but numbers do not. The IF function does not support wildcards, but you can combine IF with COUNTIF to get basic wildcard functionality. To test for substrings in a cell, you can use the IF function with the SEARCH function.

Pass or Fail example

In the worksheet shown above, we want to assign either «Pass» or «Fail» based on a test score. A passing score is 70 or higher. The formula in D6, copied down, is:

=IF(C5>=70,"Pass","Fail")

Translation: If the value in C5 is greater than or equal to 70, return «Pass». Otherwise, return «Fail».

Note that the logical flow of this formula can be reversed. This formula returns the same result:

=IF(C5<70,"Fail","Pass")

Translation: If the value in C5 is less than 70, return «Fail». Otherwise, return «Pass».

Both formulas above, when copied down, will return correct results.

Note: If you are new to the idea of formula criteria, this article explains many examples.

Assign points based on color

In the worksheet below, we want to assign points based on the color in column B. If the color is «red», the result should be 100. If the color is «blue», the result should be 125. This requires that we use a formula based on two IF functions, one nested inside the other. The formula in C5, copied down, is:

=IF(B5="red",100,IF(B5="blue",125))

Translation: IF the value in B5 is «red», return 100. Else, if the value in B5 is «blue», return 125.

Assign points based on color with the IF function

There are three things to notice in this example:

  1. The formula will return FALSE if the value in B5 is anything except «red» or «blue»
  2. The text values «red» and «blue» must be enclosed in double quotes («»)
  3. The IF function is not case-sensitive and will match «red», «Red», «RED», or «rEd».

This is a simple example of a nested IFs formula. See below for a more complex example.

Return another formula

The IF function can return another formula as a result. For example, the formula below will return A1*5% when A1 is less than 100, and A1*7% when A1 is greater than or equal to 100:

=IF(A1<100,A1*5%,A1*7%)

Nested IF statements

The IF function can be «nested». A «nested IF» refers to a formula where at least one IF function is nested inside another in order to test for more conditions and return more possible results. Each IF statement needs to be carefully «nested» inside another so that the logic is correct. For example, the following formula can be used to assign a grade rather than a pass / fail result:

=IF(C6<70,"F",IF(C6<75,"D",IF(C6<85,"C",IF(C6<95,"B","A"))))

Up to 64 IF functions can be nested. However, in general, you should consider other functions, like VLOOKUP or XLOOKUP for more complex scenarios, because they can handle more conditions in a more streamlined fashion. For a more details see this article on nested IFs.

Note: the newer IFS function is designed to handle multiple conditions without nesting. However, a lookup function like VLOOKUP or XLOOKUP is usually a better approach unless the logic for each condition is custom.

IF with AND, OR, NOT

The IF function can be combined with the AND function and the OR function. For example, to return «OK» when A1 is between 7 and 10, you can use a formula like this:

=IF(AND(A1>7,A1<10),"OK","")

Translation: if A1 is greater than 7 and less than 10, return «OK». Otherwise, return nothing («»).

To return B1+10 when A1 is «red» or «blue» you can use the OR function like this:

=IF(OR(A1="red",A1="blue"),B1+10,B1)

Translation: if A1 is red or blue, return B1+10, otherwise return B1.

=IF(NOT(A1="red"),B1+10,B1)

Translation: if A1 is NOT red, return B1+10, otherwise return B1.

IF cell contains specific text

Because the IF function does not support wildcards, it is not obvious how to configure IF to check for a specific substring in a cell. A common approach is to combine the ISNUMBER function and the SEARCH function to create a logical test like this:

=ISNUMBER(SEARCH(substring,A1)) // returns TRUE or FALSE

For example, to check for the substring «xyz» in cell A1, you can use a formula like this:

=IF(ISNUMBER(SEARCH("xyz",A1)),"Yes","No")

Read a detailed explanation here.

More information

  • Read more about nested IFs
  • Learn how to use VLOOKUP instead of nested IFs (video)
  • 50 Examples of formula criteria

Notes

  • The IF function is not case-sensitive.
  • To count values conditionally, use the COUNTIF or the COUNTIFS functions.
  • To sum values conditionally, use the SUMIF or the SUMIFS functions.
  • If any of the arguments to IF are supplied as arrays, the IF function will evaluate every element of the array.

Функция ЕСЛИ в Excel — это отличный инструмент для проверки условий на ИСТИНУ или ЛОЖЬ. Если значения ваших расчетов равны заданным параметрам функции как ИСТИНА, то она возвращает одно значение, если ЛОЖЬ, то другое.

Содержание

  1. Что возвращает функция
  2. Синтаксис
  3. Аргументы функции
  4. Дополнительная информация
  5. Функция Если в Excel примеры с несколькими условиями
  6. Пример 1. Проверяем простое числовое условие с помощью функции IF (ЕСЛИ)
  7. Пример 2. Использование вложенной функции IF (ЕСЛИ) для проверки условия выражения
  8. Пример 3. Вычисляем сумму комиссии с продаж с помощью функции IF (ЕСЛИ) в Excel
  9. Пример 4. Используем логические операторы (AND/OR) (И/ИЛИ) в функции IF (ЕСЛИ) в Excel
  10. Пример 5. Преобразуем ошибки в значения “0” с помощью функции IF (ЕСЛИ)

Что возвращает функция

Заданное вами значение при выполнении двух условий ИСТИНА или ЛОЖЬ.

Синтаксис

=IF(logical_test, [value_if_true], [value_if_false]) — английская версия

=ЕСЛИ(лог_выражение; [значение_если_истина]; [значение_если_ложь]) — русская версия

Аргументы функции

  • logical_test (лог_выражение) — это условие, которое вы хотите протестировать. Этот аргумент функции должен быть логичным и определяемым как ЛОЖЬ или ИСТИНА. Аргументом может быть как статичное значение, так и результат функции, вычисления;
  • [value_if_true] ([значение_если_истина]) — (не обязательно) — это то значение, которое возвращает функция. Оно будет отображено в случае, если значение которое вы тестируете соответствует условию ИСТИНА;
  • [value_if_false] ([значение_если_ложь]) — (не обязательно) — это то значение, которое возвращает функция. Оно будет отображено в случае, если условие, которое вы тестируете соответствует условию ЛОЖЬ.

Дополнительная информация

  • В функции ЕСЛИ может быть протестировано 64 условий за один раз;
  • Если какой-либо из аргументов функции является массивом — оценивается каждый элемент массива;
  • Если вы не укажете условие аргумента FALSE (ЛОЖЬ) value_if_false (значение_если_ложь) в функции, т.е. после аргумента value_if_true (значение_если_истина) есть только запятая (точка с запятой), функция вернет значение “0”, если результат вычисления функции будет равен FALSE (ЛОЖЬ).
    На примере ниже, формула =IF(A1> 20,”Разрешить”) или =ЕСЛИ(A1>20;»Разрешить») , где value_if_false (значение_если_ложь) не указано, однако аргумент value_if_true (значение_если_истина) по-прежнему следует через запятую. Функция вернет “0” всякий раз, когда проверяемое условие не будет соответствовать условиям TRUE (ИСТИНА).

    IF-EXCEL-01|
  • Если вы не укажете условие аргумента TRUE(ИСТИНА) (value_if_true (значение_если_истина)) в функции, т.е. условие указано только для аргумента value_if_false (значение_если_ложь), то формула вернет значение “0”, если результат вычисления функции будет равен TRUE (ИСТИНА);
    На примере ниже формула равна =IF (A1>20;«Отказать») или =ЕСЛИ(A1>20;»Отказать»), где аргумент value_if_true (значение_если_истина) не указан, формула будет возвращать “0” всякий раз, когда условие соответствует TRUE (ИСТИНА).

IF EXCEL - 02

Функция Если в Excel примеры с несколькими условиями

Пример 1. Проверяем простое числовое условие с помощью функции IF (ЕСЛИ)

При использовании функции ЕСЛИ в Excel, вы можете использовать различные операторы для проверки состояния. Вот список операторов, которые вы можете использовать:

IF-EXCEL-03

Ниже приведен простой пример использования функции при расчете оценок студентов. Если сумма баллов больше или равна «35», то формула возвращает “Сдал”, иначе возвращается “Не сдал”.

Excel-IF-04

Пример 2. Использование вложенной функции IF (ЕСЛИ) для проверки условия выражения

Функция может принимать до 64 условий одновременно. Несмотря на то, что создавать длинные вложенные функции нецелесообразно, то в редких случаях вы можете создать формулу, которая множество условий последовательно.

В приведенном ниже примере мы проверяем два условия.

  • Первое условие проверяет, сумму баллов не меньше ли она чем 35 баллов. Если это ИСТИНА, то функция вернет “Не сдал”;
  • В случае, если первое условие — ЛОЖЬ, и сумма баллов больше 35, то функция проверяет второе условие. В случае если сумма баллов больше или равна 75. Если это правда, то функция возвращает значение “Отлично”, в других случаях функция возвращает “Сдал”.

Excel-If-06

Пример 3. Вычисляем сумму комиссии с продаж с помощью функции IF (ЕСЛИ) в Excel

Функция позволяет выполнять вычисления с числами. Хороший пример использования — расчет комиссии продаж для торгового представителя.

В приведенном ниже примере, торговый представитель по продажам:

  • не получает комиссионных, если объем продаж меньше 50 тыс;
  • получает комиссию в размере 2%, если продажи между 50-100 тыс
  • получает 4% комиссионных, если объем продаж превышает 100 тыс.

Рассчитать размер комиссионных для торгового агента можно по следующей формуле:

=IF(B2<50,0,IF(B2<100,B2*2%,B2*4%)) — английская версия

=ЕСЛИ(B2<50;0;ЕСЛИ(B2<100;B2*2%;B2*4%)) — русская версия

Excel-IF-07

В формуле, использованной в примере выше, вычисление суммы комиссионных выполняется в самой функции ЕСЛИ. Если объем продаж находится между 50-100K, то формула возвращает B2 * 2%, что составляет 2% комиссии в зависимости от объема продажи.

Telegram Logo Больше лайфхаков в нашем Telegram Подписаться

Пример 4. Используем логические операторы (AND/OR) (И/ИЛИ) в функции IF (ЕСЛИ) в Excel

Вы можете использовать логические операторы (AND/OR) (И/ИЛИ) внутри функции для одновременного тестирования нескольких условий.

Например, предположим, что вы должны выбрать студентов для стипендий, основываясь на оценках и посещаемости. В приведенном ниже примере учащийся имеет право на участие только в том случае, если он набрал более 80 баллов и имеет посещаемость более 80%.

Excel-If-09

Вы можете использовать функцию AND (И) вместе с функцией IF (ЕСЛИ), чтобы сначала проверить, выполняются ли оба эти условия или нет. Если условия соблюдены, функция возвращает “Имеет право”, в противном случае она возвращает “Не имеет право”.

Формула для этого расчета:

=IF(AND(B2>80,C2>80%),”Да”,”Нет”) — английская версия

=ЕСЛИ(И(B2>80;C2>80%);»Да»;»Нет») — русская версия

Excel-IF-10

Пример 5. Преобразуем ошибки в значения “0” с помощью функции IF (ЕСЛИ)

С помощью этой функции вы также можете убирать ячейки содержащие ошибки. Вы можете преобразовать значения ошибок в пробелы или нули или любое другое значение.

Формула для преобразования ошибок в ячейках следующая:

=IF(ISERROR(A1),0,A1) — английская версия

=ЕСЛИ(ЕОШИБКА(A1);0;A1) — русская версия

Формула возвращает “0”, в случае если в ячейке есть ошибка, иначе она возвращает значение ячейки.

ПРИМЕЧАНИЕ. Если вы используете Excel 2007 или версии после него, вы также можете использовать функцию IFERROR для этого.

Точно так же вы можете обрабатывать пустые ячейки. В случае пустых ячеек используйте функцию ISBLANK, на примере ниже:

=IF(ISBLANK(A1),0,A1) — английская версия

=ЕСЛИ(ЕПУСТО(A1);0;A1) — русская версия

EXCEL-IF-11

The logical IF statement in Excel is used for the recording of certain conditions. It compares the number and / or text, function, etc. of the formula when the values correspond to the set parameters, and then there is one record, when do not respond — another.

Logic functions — it is a very simple and effective tool that is often used in practice. Let us consider it in details by examples.



The syntax of the function «IF» with one condition

The operation syntax in Excel is the structure of the functions necessary for its operation data.

=IF(boolean;value_if_TRUE;value_if_FALSE)

Let us consider the function syntax:

  • Boolean – what the operator checks (text or numeric data cell).
  • Value_if_TRUE – what will appear in the cell when the text or numbers correspond to a predetermined condition (true).
  • Value_if_FALSE – what appears in the box when the text or the number does not meet the predetermined condition (false).

Example:

Example.

Logical IF functions.

The operator checks the A1 cell and compares it to 20. This is a «Boolean». When the contents of the column is more than 20, there is a true legend «greater 20». In the other case it’s «less or equal 20».

Attention! The words in the formula need to be quoted. For Excel to understand that you want to display text values.

Here is one more example. To gain admission to the exam, a group of students must successfully pass a test. The results are listed in a table with columns: a list of students, a credit, an exam.

list.

The statement IF should check not the digital data type but the text. Therefore, we prescribed in the formula В2= «done» We take the quotes for the program to recognize the text correctly.



The function IF in Excel with multiple conditions

Usually one condition for the logic function is not enough. If you need to consider several options for decision-making, spread operators’ IF into each other. Thus, we get several functions IF in Excel.

The syntax is as follows:

Here the operator checks the two parameters. If the first condition is true, the formula returns the first argument is the truth. False — the operator checks the second condition.

Examples of a few conditions of the function IF in Excel:

few conditions.

It’s a table for the analysis of the progress. The student received 5 points:

  • А – excellent;
  • В – above average or superior work;
  • C – satisfactory;
  • D – a passing grade;
  • E – completely unsatisfactory.

IF statement checks two conditions: the equality of value in the cells.

two conditions.

In this example, we have added a third condition, which implies the presence of another report card and «twos». The principle of the operator is the same.

Enhanced functionality with the help of the operators «AND» and «OR»

When you need to check out a few of the true conditions you use the function И. The point is: IF A = 1 AND A = 2 THEN meaning в ELSE meaning с.

OR function checks the condition 1 or condition 2. As soon as at least one condition is true, the result is true. The point is: IF A = 1 OR A = 2 THEN value B ELSE value C.

Functions AND & OR can check up to 30 conditions.

An example of using the operator AND:

operator AND.

It’s the example of using the logical operator OR.

example of using OR.

How to compare data in two tables

Users often need to compare the two spreadsheets in an Excel to match. Examples of the «life»: compare the prices of goods in different bringing, to compare balances (accounting reports) in a few months, the progress of pupils (students) of different classes, in different quarters, etc.

To compare the two tables in Excel, you can use the COUNTIFS statement. Consider the order of application functions.

For example, consider the two tables with the specifications of various food processors. We planned allocation of color differences. This problem in Excel solves the conditional formatting.

Baseline data (tables, which will work with):

tables.

Select the first table. Conditional Formatting — create a rule — use a formula to determine the formatted cells:

formatted cells.

In the formula bar write: = COUNTIFS (comparable range; first cell of first table)=0. Comparing range is in the second table.

To drive the formula into the range, just select it first cell and the last. «= 0» means the search for the exact command (not approximate) values.

Choose the format and establish what changes in the cell formula in compliance. It’s better to do a color fill.

Select the second table. Conditional Formatting — create a rule — use the formula. Use the same operator (COUNTIFS). For the second table formula:

Download all examples in Excel

compare the characteristics.

Now it is easy to compare the characteristics of the data in the table.

Понравилась статья? Поделить с друзьями:
  • Excel if cell is not empty formula
  • Excel if cell integer
  • Excel if cell filled color
  • Excel if cell ends with you
  • Excel if cell contains text or text