Forum Discussion

nic-nicol's avatar
nic-nicol
Copper Contributor
Jan 17, 2021
Solved

Trying to toggle colour of shapes on mouse click

I'm putting shapes over a picture of a human body so you can click an area, say upper left leg, and it's highlighted, click again returns to transparent so you just see the picture below.   I've go...
  • HansVogelaar's avatar
    Jan 17, 2021

    nic-nicol 

    You need only a single macro that you assign to all the shapes:

     

    Sub ChangeFill()
        With ActiveSheet.Shapes(Application.Caller).Fill
            .Visible = Not .Visible
        End With
    End Sub

     

    Please note that when the interior of a shape is transparent, you'll have to click on its edge to run the macro; clicking inside the shape won't work (precisely because it is transparent).

Resources