How to Make Yes Green and No Red in Excel (5 Examples)

Table of Contents

Table of Contents

Highlighting “Yes” and “No” in Excel with different colours helps make datasets more readable and visually appealing. It is especially helpful for displaying datasets with repetitive values, where quick identification is important. By using Excel’s built-in tools and options, we can easily perform this task.

Key Takeaways

Follow the steps below to highlight “Yes” as Green and “No” as Red in your dataset.

➤ Start by selecting the range of cells that you want to highlight, then from the main menu, head to Conditional Formatting >> Highlight Cell Rules >> Text that Contains.
➤ Type “Yes” in the Format cells that contain the text field, then select Green Fill with Dark Green Text and click OK to highlight “Yes” in green.
➤ Type “No” in the Format cells that contain the text field, then select Light Red Fill with Dark Red Text and click OK to highlight “No” in red.

overview image

In this article, we will learn five effective methods of making “Yes” green and “No” red in Excel.

Download Practice Workbook
1

Highlight Yes in Green and No in Red Using Conditional Formatting Highlight Cell Rules

In the sample dataset, we have a worksheet called “Student Grades” containing information about Student names, Subject, Score, and their Pass status.

Highlight Yes in Green and No in Red Using Conditional Formatting Highlight Cell Rules

By using the Highlight Cell Rules option from the Conditional Formatting tool, we will format column D so that “Yes” appears in green and “No” appears in red in the dataset. We will display the updated dataset in a separate “Highlight Cell Rules” worksheet.

Highlight Cell Rules is a useful Excel feature that allows users to quickly format cells based on specific conditions, such as values greater than, less than, equal to, or containing certain text, dates, or duplicates.

Steps:

➤ Head to the Highlight Cell Rules worksheet and select cells D2 to D13.

Highlight Yes in Green and No in Red Using Conditional Formatting Highlight Cell Rules

➤ Now, from the main menu, navigate to Conditional Formatting >> Highlight Cell Rules >> Text that Contains.

Highlight Yes in Green and No in Red Using Conditional Formatting Highlight Cell Rules

➤ Enter “Yes” in the Format cells that contain the text box, choose Green Fill with Dark Green Text, and click OK to format “Yes” in green.

Highlight Yes in Green and No in Red Using Conditional Formatting Highlight Cell Rules

➤ Again select cells D2 to D13 and head to Conditional Formatting >> Highlight Cell Rules >> Text that Contains from the main menu.

Highlight Yes in Green and No in Red Using Conditional Formatting Highlight Cell Rules

➤ Next, enter “No” in the Format cells that contain the text box, choose Light Red Fill with Dark Red Text, and click OK to format “No” in red.

Highlight Yes in Green and No in Red Using Conditional Formatting Highlight Cell Rules

➤ Your dataset should now highlight “Yes” in green and “No” in red.


2

Make Yes Green and No Red Using Custom Conditional Formatting Rules

Conditional Formatting is an important tool in Excel that allows users to automatically apply formatting such as colours, icons, or data bars based on user-defined cell rules.

Using the same dataset, we will now apply conditional formatting in column D by creating a new rule that highlights “Yes” in green and “No” in red. The updated dataset will be stored in a separate “New Rule” worksheet.

Steps:

➤ Open the New Rule worksheet and select range D2:D13.

Make Yes Green and No Red Using Custom Conditional Formatting Rules

➤ From the main menu, head to Conditional Formatting >> New Rule.

Make Yes Green and No Red Using Custom Conditional Formatting Rules

➤ From the New Formatting Rule dialogue box, select Use a formula to determine which cells to format option. Then, in the Format values where this formula is true field, enter the following formula and click Format:

=ISNUMBER(SEARCH("Yes",$D2))

Make Yes Green and No Red Using Custom Conditional Formatting Rules

Explanation
In the formula, SEARCH function checks if “Yes” is present in each cell, and ISNUMBER returns TRUE when it is found. Conditional formatting then applies the green fill to those TRUE cases.

➤ Next, in the Format Cells dialogue box, go to the Fill tab, choose a green colour, and click OK.

Make Yes Green and No Red Using Custom Conditional Formatting Rules

➤ Finally, click OK in the New Formatting Rule dialogue box to apply the rule.

Make Yes Green and No Red Using Custom Conditional Formatting Rules

➤ Again select the range D2:D13 and head to Conditional Formatting >> New Rule.

Make Yes Green and No Red Using Custom Conditional Formatting Rules

➤ Select Use a formula to determine which cells to format option, enter the following formula under Format values where this formula is true field and click on Format.

=ISNUMBER(SEARCH("No",$D2))

Explanation
In the formula, SEARCH function checks if “No” is present in each cell, and ISNUMBER returns TRUE when it is found. Conditional formatting then applies the red fill to those TRUE cases.

➤ Next, select red as fill colour from the Fill tab and click on OK.

➤ Click OK to complete the operation.

➤ The dataset should now highlight “Yes” in green and “No” in red.


3

Use the Filter Tool to Highlight Yes and No

The Filter Tool in Excel is a useful feature that allows users to display only the rows that meet specific criteria while temporarily hiding the rest.

Working again with the same dataset, we will now apply the Filter Tool to column D for highlighting “Yes” in green and “No” in red within the dataset. We will display the modified dataset in a separate “Filter Tool” worksheet.

Steps:

➤ Open the Filter Tool worksheet and select cells D2 to D13.

Use the Filter Tool to Highlight Yes and No

➤ Then, from the main menu, head to Data >> Sort & Filter >> Filter.

Use the Filter Tool to Highlight Yes and No

➤ Click the Filter icon next to cell D2, uncheck all options except “Yes” and click OK.

Use the Filter Tool to Highlight Yes and No

➤ Next, go to the Home tab, select a green fill colour, and apply it to all cells containing “Yes”.

Use the Filter Tool to Highlight Yes and No

➤ Once again, click the Filter icon in cell D2, this time check only the “No” option, and then click OK.

Use the Filter Tool to Highlight Yes and No

➤ Go to the Home tab again, select a red fill colour, and apply it to all cells containing “No”.

Use the Filter Tool to Highlight Yes and No

➤ Click Filter icon for the last time and check all boxes.

Use the Filter Tool to Highlight Yes and No

Note:
To remove the filter icon, select cells D2 to D13 and navigate to Data >> Sort & Filter >> Filter.

➤ “Yes” in red and “No” in green should now be visible in column D.

Use the Filter Tool to Highlight Yes and No


4

Automatically Highlight Yes Green and No Red Using VBA Editor

Excel’s VBA Editor is a powerful tool that allows users to write and run custom macros for automating tasks. We can also use it to automatically highlight cells with the colours we want, based on specific values or conditions.

Using the same dataset again, we will now use VBA Editor to highlight Yes and No values in column D in green and red, respectively. The modified dataset will be displayed in a separate “VBA Editor” worksheet.

Steps:

➤ Open the VBA Editor worksheet and press  Alt  +  F11  to launch the VBA Editor window.

Automatically Highlight Yes Green and No Red Using VBA Editor

➤ In the Microsoft VBA Editor dialogue box, go to Insert >> Module from the main menu, and then paste the following code:

Sub ApplyStatusCF()
    Dim ws As Worksheet, rng As Range
    Set ws = ActiveSheet
    Set rng = ws.Range("D2:D13")
    rng.FormatConditions.Delete
    ' PASS = green
    With rng.FormatConditions.Add(Type:=xlExpression, Formula1:="=LOWER(TRIM($D2))=""Yes""")
        .Interior.colour = RGB(198, 239, 206)
        .Font.colour = RGB(0, 97, 0)
    End With
    ' FAIL = red
    With rng.FormatConditions.Add(Type:=xlExpression, Formula1:="=LOWER(TRIM($D2))=""No""")
        .Interior.colour = RGB(255, 199, 206)
        .Font.colour = RGB(156, 0, 6)
    End With
End Sub

Automatically Highlight Yes Green and No Red Using VBA Editor

Explanation
The macro “ApplyStatusCF” applies conditional formatting to the range D2:D13 in the active sheet, clearing any existing rules first. It highlights cells containing “Yes” with a light green fill and dark green text, and cells containing “No” with a light red fill and dark red text.

➤ Now, press  Alt  +  F8  to open the Macros dialogue box, select the ApplyStatusCF macro, and click Run.

Automatically Highlight Yes Green and No Red Using VBA Editor

➤ “Yes” in green and “No” in red should now automatically be highlighted in the dataset.

Automatically Highlight Yes Green and No Red Using VBA Editor


5

Make Yes Green and No Red with Office Scripts

Office Scripts is another powerful tool in Excel that enables users to automate repetitive tasks, record actions, and create custom scripts for streamlining workflows.

We will use the same dataset and write an Office Script to automatically highlight the cells in column D with green and red colours. The updated dataset will be stored in a separate worksheet called “Office Script”.

Steps:

➤ Open the Office Script worksheet and from the main menu, head to Automate >> New Script.

Make Yes Green and No Red with Office Scripts

➤ In the Code Editor pane, paste the following script and click on Run:

function main(workbook: ExcelScript.Workbook) {
    const ws = workbook.getActiveWorksheet()
    const used = ws.getUsedRange(true)
    if (!used) return
    const totalRows = used.getRowCount()
    if (totalRows < 2) return
    const rng = ws.getRangeByIndexes(1, 3, totalRows - 1, 1)
    rng.clear(ExcelScript.ClearApplyTo.formats)
    const values = rng.getValues()
    for (let r = 0; r < values.length; r++) {
        const text = String(values[r][0]).trim().toLowerCase()
        const cell = rng.getCell(r, 0)
        const fmt = cell.getFormat()
        if (text === "yes") {
            fmt.getFill().setColor("#C6EFCE")
            fmt.getFont().setColor("#006100")
        } else if (text === "no") {
            fmt.getFill().setColor("#FFC7CE")
            fmt.getFont().setColor("#9C0006")
        }
    }
}

Make Yes Green and No Red with Office Scripts

Explanation
This Office Script applies custom formatting to responses in column D of the active worksheet. After identifying the used range, the script clears any existing formatting in that column and then evaluates each cell’s content. If the value is “Yes”, the script formats the cell with a light green background and dark green text. If the value is “No”, the cell is formatted with a light red background and dark red text. All other values remain unformatted.

➤ The dataset will now automatically highlight “Yes” in green and “No” in red.

Make Yes Green and No Red with Office Scripts


Frequently Asked Questions

What Happens If My Dataset Has Blank Cells in the Column?

For all the methods discussed in this article, blank cells in the column will be ignored by default. Conditional Formatting rules, and Filter only apply changes to cells that meet specific conditions, while VBA and Office Scripts skip over blank cells, applying formatting only to those containing actual values.

Which Method is Best For Large Datasets?

For large datasets, the VBA Editor and Office Script methods are the most efficient. They apply formatting automatically across the dataset, saving time and reducing manual effort.


Concluding Words

Knowing how to highlight “Yes” green and “No” red in an Excel dataset is crucial for improving data readability and analysis. In this article, we have discussed five effective methods on how to make yes green and no red in Excel, including using Conditional Formatting Rules, Filter Tool, VBA Editor and Office Scripts. Feel free to try out each method and select one that best aligns with your needs.

Facebook
X
LinkedIn
WhatsApp
Picture of Mashrur Ibne Shams

Mashrur Ibne Shams

Mashrur Ibne Shams holds a BSc in Industrial and Production Engineering and is a Certified Supply Chain Analyst (CSCA). With 3 years of Excel and Google Sheets experience, he specializes in data cleaning, text extraction, advanced formulas, dynamic arrays, VBA automation, and Power Query. He has created step-by-step tutorials and custom VBA scripts for real-world datasets. He enjoys simplifying complex tasks, automating processes, and organizing data efficiently.
We will be happy to hear your thoughts

      Leave a reply

      Excel Insider
      Logo