Excel VBA Function Cell Background Color

This post details how to setup a simple function in Excel, using VBA to find the background color of a given cell.  The result will display the text description of the background color.  This allows further utilization in formulas, which was the use case for creating this function.

Excel VBA Function Cell Background Color

This post uses Excel 2013 in Windows 10.

In Excel, there are 10 standard colors included in the color palette:

Excel VBA Function Cell Background Color

The following function will return the referenced cell’s interior color value:

In Excel, I simply added the 10 standard background colors in column A, starting with no background in cell A1.

Then, in Column B, I added following formula, using function above:

Formula in cell B1 (copy down to B11):  =BGCol(A1)

Results look like this:

Excel VBA Function Cell Background Color

Taking this a step further, I then wanted to display the function result as the actual color text description.  Added the following function, building upon the first:

Next, add the following formula in cell C1 (copy down to C11):  =BGC(A1)

Results look like this:

Excel VBA Function Cell Background Color

There you have it!  Please modify to suit your needs.

 

Additional Content

Check out more examples by visiting my Home Page

Here you will find topics covering  Qlikview  SQL Server  Excel VBA

 

 

 

Leave a Comment