VBA: How can I remove Cell Fill Colors?

VBA allows you to remove cell fill colors from a range of cells by using the range.Interior.ColorIndex property. This property sets the background color of a range to the default (white) and can be set to either -4142 (default) or 0 (white) to remove the cell fill color. The syntax for this is Range(“A1:A10”).Interior.ColorIndex = -4142 or Range(“A1:A10”).Interior.ColorIndex = 0.


You can use the following basic syntax in VBA to remove borders from cells in a specific range:

Sub RemoveFillColor()
Range("A1:B12").Interior.Color = xlNone
End Sub

This particular example removes all fill colors from the cells in the range A1:B12.

The following example shows how to use this syntax in practice.

Example: Using VBA to Remove Cell Fill Colors

Suppose we have the following dataset in Excel that contains information about various basketball players:

Suppose we would like to remove the fill colors from each cell in the range A1:B12.

We can create the following macro to do so:

Sub RemoveFillColor()
Range("A1:B12").Interior.Color = xlNone
End Sub

When we run this macro, we receive the following output:

Notice that the fill colors in each cell in the range A1:B12 have been removed.

To remove the fill colors from cells in a different range, simply change A1:B12 to a different range within the macro.

Note: You can find the complete documentation for the VBA Interior.Color property .

The following tutorials explain how to perform other common tasks using VBA:

x