How can I create an Excel formula that performs a specific action if a cell is formatted with the color green?

To create an Excel formula that performs a specific action if a cell is formatted with the color green, you can use the “IF” function along with the “CELL” function. The “IF” function allows you to test a condition and perform different actions based on the result. The “CELL” function, when used with the “color” argument, returns the color index of a cell. By combining these two functions, you can specify that if the color index of a cell is equal to the index of the color green, the formula will perform a specific action, such as displaying a message or performing a calculation. This allows you to easily identify and handle cells that are formatted with the color green in your Excel spreadsheet.

Excel Formula: If Cell Color is Green Then Do Something


Often you may want to use an IF statement in Excel to perform some action if a cell color is green.

Fortunately this is easy to do by creating a Defined Name in Excel that can check whether or not a cell is green.

The following example shows how to do so in practice.

Example: If Cell Color is Green Then Do Something in Excel

Suppose we have the following list of basketball players in Excel in which the green cells indicate that the player is an All-Star:

Suppose we would like to use an IF statement to check if each cell color in column A is green and return either “All-Star” or “Not All-Star” in column B.

To do so, we can click the Formulas tab along the top ribbon, then click the Name Manager icon:

In the new window that appears, click the New button in the top left corner:

In the new window that appears, type GreenCell in the Name box, then type =GET.CELL(38,Sheet1!A2) in the Refers to box, then click OK:

Next, type =GreenCell in cell B2, then click and drag this formula down to each cell in column B:

We can see that the formula returns a color code of 35 for each corresponding cell in column A that is green.

Now that we know which color code represents this shade of green, we can type the following formula into cell B2 to return “All-Star” if the corresponding cell in column A is green or “Not All-Star” otherwise:

=IF(GreenCell=35, "All-Star", "Not All-Star")

We can then click and drag this formula down to each remaining cell in column B:

Excel if cell color is green then

Column B now returns “All-Star” or “Not All-Star” depending on whether or not the corresponding cell in column A is green.

Note that in this particular example, the shade of green that we used had a color code of 35.

However, different shades of green will have a different color code, which is why we created the GreenCell custom formula to actually extract the color code before we created the IF statement.

Additional Resources

The following tutorials explain how to perform other common operations in Excel:

x