If/else/then statements
Conditional statements is our next topic at hand. This functionality will give you, the Excel developer, more control, power, and freedom. You will now be able to add intelligence to your spreadsheets and the following examples will tell you how to do this:
Fire up Excel 2013 and create a new spreadsheet. Manually enter the following information:
Column B tells us how much inventory we currently have on hand. In column C, we will determine whether we need to buy more inventory. Column D will tell us whether we have to buy more inventory and how much inventory we have to buy. We are going to make the assumption that we cannot have more than 200 items in our inventory. In other words, we cannot have more than 200 apples, 200 grapes, and so on.
How are we going to determine whether we are low in inventory? We are going to use Excel's conditional statements.
In cell C2, type
=if(B2<200,"yes","no")
, as shown in the following screenshot. How does theif
function work? The...