Conditional Formatting Based on Cell Color

If you want to use conditional formatting where a criterion is a cell color, you can’t just use standard conditional formatting. You have to create a VBA function that will recognize color and apply adequate formatting.

In this tutorial, we are going to create a formula that will name a color based on the cell background.

Let’s take standard colors from the Excel palette. You can find them in Home >> Font >> Fill Color >> Standard Colors.

Let’s display them inside cells, from A2 to A11.

Now, let’s create a function that will identify colors. Open the VBA window by pressing Left Alt + F11.

Create a new module: right-click project >> Insert >> Class Module.

Start typing the function name inside column B2 and AutoFill the rest of the cells.

These numbers don’t tell us much. Let’s modify our function to apply names to these colors.

Tomasz Decker is an Excel specialist, skilled in data analysis and financial modeling.

Posted in vba