Forum Discussion
Kai3313
May 05, 2022Copper Contributor
Shape color toggling
Hello. I am new to VBA. And I am working on a project we’re I’m using a shape as a button . I’m trying to have the code change the fill and text color on a click and then back if clicked again. So th...
HansVogelaar
May 05, 2022MVP
Assign this macro to the shape. You can add other code too of course.
Sub ClickMe()
Dim shp As Shape
Dim clr As Long
Set shp = ActiveSheet.Shapes(Application.Caller)
clr = shp.Fill.ForeColor.RGB
shp.Fill.ForeColor.RGB = shp.TextFrame.Characters.Font.Color
shp.TextFrame.Characters.Font.Color = clr
End Sub