In this article, you will learn how to change background colors of cells in Excel VBA and apply them in your Excel spreadsheet.
Change Background Colors of Cells in Excel VBA
You can use the Interior property to return an Interior object. Then use the ColorIndex property of the Interior object to set the background color of a cell.
To Change Background Colors in Excel VBA, follow the below steps
You can use both cell and range methods to change the background.
Let’s see the Range method.
Place three command buttons on your worksheet
This code will change the background color of cell A1 to Dark blue.
Range("A1").Interior.ColorIndex = 57
This code will change the background color of cell A1 to ‘No Fill’.
Range("A1").Interior.ColorIndex = 0
To know the color index
Select cell A1 and click the command button on the sheet.