You can use the following basic syntax to create an IF function in Excel that returns “Yes” or “No” as a result:
=IF(A2>=B2, "Yes", "No")
For this particular formula, if the value in cell A2 is greater than or equal to the value in cell B2, the function returns “Yes.”
Otherwise it returns “No.”
The following examples show how to use this syntax in practice.
Example: Create IF Function to Return Yes or No in Excel
Suppose we have the following two columns in Excel that show the sales and sales targets for ten different products:

We can type the following formula into cell C2 to return “Yes” if the number of sales in cell A2 is equal to or greater than the sales target in cell B2:
=IF(A2>=B2, "Yes", "No")
We can then drag and fill this formula down to each remaining cell in column C:

The formula returns either “Yes” or “No” depending on whether or not the sales value in column A is greater than or equal to the sales target in column B.
Note that you can place any logical test you’d like in the first argument of the IF function.
For example, you could use <> to test if the values in cell A2 and B2 are not equal to each other and return “Yes” if they’re not equal or “No” if they are equal:
=IF(A2<>B2, "Yes", "No")
We can then drag and fill this formula down to each remaining cell in column C:

The formula returns “Yes” if the sales and sales target are not equal.
Otherwise, the formula returns “No” if the sales and sales target are equal.
Feel free to use whatever logical test you’d like in the first argument of the IF function depending on what condition you’d like to test.
Additional Resources
The following tutorials explain how to perform other common tasks in Excel:
Excel: How to Use an IF Function with 3 Conditions
Excel: How to Use an IF Function with Range of Values
Excel: How to Use an IF Function with Dates
Hi Zach, I am trying to create a formula to minus 2 business days from the required date of a specific part number. So I only want part numbers ending in SA to have a calculated date of 2 business days before it is due.
Hi Jessica…Hi,
I’d be happy to help you create the Excel formula you need!
—
**Objective:**
– **For part numbers ending with ‘SA’**, calculate a date that is **2 business days before** the required date.
– **For all other part numbers**, you can either keep the required date unchanged or leave the cell blank, depending on your preference.
—
### **Step-by-Step Guide**
#### **Assumptions:**
– **Part Number** is in **column A** (e.g., cell **A2**).
– **Required Date** is in **column B** (e.g., cell **B2**).
– You want the **Calculated Date** in **column C**.
#### **1. Check if Part Number Ends with ‘SA’**
Use the `RIGHT` function to extract the last two characters of the part number and compare it to `’SA’`.
#### **2. Subtract 2 Business Days**
Use the `WORKDAY` function to subtract 2 business days from the required date. The `WORKDAY` function automatically excludes weekends (Saturday and Sunday).
#### **3. Combine Using IF Function**
Use the `IF` function to apply the calculation only to part numbers ending with `’SA’`.
—
### **Formula**
Place the following formula in cell **C2**:
“`excel
=IF(RIGHT(A2,2)=”SA”, WORKDAY(B2, -2), B2)
“`
**Explanation:**
– **`RIGHT(A2,2)=”SA”`**: Checks if the last two characters of the part number in cell **A2** are `’SA’`.
– **`WORKDAY(B2, -2)`**: Subtracts 2 business days from the date in cell **B2**.
– **`B2`**: If the part number does not end with `’SA’`, the formula returns the original required date.
**Note:** If you prefer to leave the cell blank when the part number does not end with `’SA’`, replace `B2` with `””` in the formula:
“`excel
=IF(RIGHT(A2,2)=”SA”, WORKDAY(B2, -2), “”)
“`
—
### **Example**
Suppose your data looks like this:
| **A** (Part Number) | **B** (Required Date) |
|———————|———————–|
| 12345SA | 10/20/2023 |
| 67890AB | 10/20/2023 |
Applying the formula:
– **For A2 (`12345SA`):**
– `RIGHT(A2,2)` returns `’SA’`.
– Condition is `TRUE`, so it calculates `WORKDAY(B2, -2)`.
– If `B2` is `10/20/2023` (a Friday), subtracting 2 business days gives `10/18/2023` (Wednesday).
– **For A3 (`67890AB`):**
– `RIGHT(A3,2)` returns `’AB’`.
– Condition is `FALSE`, so it returns the original date in `B3`, which is `10/20/2023`.
—
### **Handling Holidays (Optional)**
If you need to exclude holidays in addition to weekends:
1. **Create a List of Holiday Dates:**
– Enter your holiday dates in a range of cells, e.g., **F2:F10**.
– It’s a good idea to name this range `Holidays` for easy reference.
2. **Name the Range (Optional but Recommended):**
– Select the holiday date cells (e.g., `F2:F10`).
– Click in the **Name Box** (to the left of the formula bar), type `Holidays`, and press **Enter**.
3. **Modify the Formula to Include Holidays:**
“`excel
=IF(RIGHT(A2,2)=”SA”, WORKDAY(B2, -2, Holidays), B2)
“`
– This formula now subtracts 2 business days, excluding weekends and the dates specified in your `Holidays` range.
—
### **Additional Tips**
– **Copy the Formula Down:**
– After entering the formula in **C2**, you can drag the fill handle down to apply it to other rows.
– **Ensure Correct Cell Formatting:**
– Make sure that the cells containing dates are formatted as **Date**.
– **Error Checking:**
– If you encounter any errors, double-check that:
– The part numbers are correctly entered.
– The dates are valid and formatted properly.
– The `Holidays` range (if used) is correctly named and contains valid dates.
—
### **Final Formula Recap**
– **Without Holidays:**
“`excel
=IF(RIGHT(A2,2)=”SA”, WORKDAY(B2, -2), B2)
“`
– **With Holidays:**
“`excel
=IF(RIGHT(A2,2)=”SA”, WORKDAY(B2, -2, Holidays), B2)
“`
—
### **Summary**
– **Objective:** Subtract 2 business days from the required date for part numbers ending with `’SA’`.
– **Key Functions Used:**
– `IF` for conditional logic.
– `RIGHT` to check the end of the part number.
– `WORKDAY` to calculate business days.
—