If else in Excel
If else is used in Excel, through the IF function, to test the validity of a particular condition.
=IF(test,true result,false result)
This formula works by returning the true value as specified in a cell and returns the false value if it’s found otherwise.
To explain this better, we would use an example.
We would consider an Excel spreadsheet that has a list of objects with certain characteristics. In this case, let’s use the conditions of cars – old and new, which are represented by O and N respectively.
Figure 1: Objects to be returned by the IF function.
The next step would be to use the formula for the IF function. The function, in its application, would naturally return “New” for a cell that contains “N”. On the other hand, it returns “Old” for cells with “O” in them.
Figure 2. The IF function returns the true value of the cell.
To get the values of the remaining cells, simply drag the first column, C3, to “C9”. This action populates every cell with the condition of each car.
Figure 3. The IF function returns the conditions of all the cars in the Excel spreadsheet.
From our example, you would observe that we’ve only tested for one of the two possibilities, “N”. it is so for the simple reason that we have just two possible occurrences in this case. So, the “false result” in the formula automatically picks the only one that isn’t true.