Question: I'm very new to macros and I'm trying to teach myself VBA in excel 2013 and could use a lot of help. I would like to know how to change a shape fill color (not a cell) when I click an ActiveX button. Here is what I'm thinking:

```
onClick()                            <-- Do I need a button name?
if shape.color = RGB(231,230,230)    <-- this is the starting color
    shape.color = RGB(0,0,0)         <-- this is what I want to change it to
else
    shape.color = RGB(231,230,230)   <-- if color is black change to this
end if

```

By the way, this is for fun and not for anything special or official.

Answer: 
Put this in the module of the worksheet which contains the button:

EDITED: Sorry, I originally thought you wanted the actual button colour to change. I borrowed from Ralph's answer to account for the shape being the object of the colour change, but below this is for an ActiveX control (as you asked) instead of a form button:

```
Private Sub CommandButton1_Click() ' Yes, you do need to specify the button
    Dim shp As Shape
    Set shp = ThisWorkbook.Worksheets(1).Shapes("Rectangle 1")
    If shp.Fill.ForeColor.RGB = RGB(231, 230, 230) Then
        shp.Fill.ForeColor.RGB = RGB(0, 0, 0)
    Else
        shp.Fill.ForeColor.RGB = RGB(231, 230, 230)
    End If
End Sub

```
Yes, you need a button name. Drop an ActiveX control on the sheet, then go to the sheet's module in the VBE. In the left dropdown at the top of the code pane, find your control name (you probably want to rename it first - I didn't for this example)

[![enter image description here](https://i.stack.imgur.com/FKgXI.gif)](https://i.stack.imgur.com/FKgXI.gif)

When you pick the control name in the left dropdown and the event name in the right, the VBE stubs the Sub and End Sub for you.

Next you need to reference your shape in your code. Start by using the `Me` keyword. When you're in a sheet's code module, `Me` refers to that sheet. Then the dot operator will expose all the properties and methods of that sheet. When you drop an ActiveX control on a sheet, a new property of the sheet is automatically created that provides access to the object. You can use

```
Me.CommandButton1.BackColor = RGB(231, 230, 230)

```

You `If` logic looks fine.