Change shape color with VBA – How-to

This quick how-to snapshot shows you how to change shape color with VBA. For the purpose of this snapshot, the main focus is the VBA code.

How-to change shape color with VBA

So, in these snapshots, we will show you the worksheet and the code. Again, the main focal point is the VBA code.


To make this work, we just need a worksheet with a box and code to push the update.

The worksheet

Change shape color with VBA - How-to - Techronology

Firstly, we have a worksheet that contains a box and a form button. We link the form button to the Change_Color macro. Now, you do not need to create the button. You can just run the macro from the Developer tab. But sometimes, we get kind of lazy.

The code

Secondly, we need macro code to make the color change. Basically, once the user clicks on the button, the box will change to RGB color 70, 114, and 196. RGB is short for red, green, and blue. Thus, you mix those together to get a color. In our case, a bluish color.

If you are familiar with VBA, then you can change the RGB property to Hex or another color code.

Code listing

Below is the code, which you can select.

Sub Change_Color()
    ActiveSheet.Shapes.Range("Rectangle 1").Fill.ForeColor.RGB = RGB(70, 114, 196)
End Sub

So, you may not need ActiveSheet at the beginning. However, we did not test it.

Running the macro

Follow these steps to change the color of the box.

  1. Change the color of the box
  2. Click the Change color button

That is all to it. Enjoy!


Here is some related information to this snapshot.

Snapshots Training home