Hi all,
I tried to use this code to change the color of each clicked square.
It worked perfectly for the first squares, but the squares that are orange in the image below resulted in an error when clicked.
The line
Set sh = ActiveSheet.Shapes(Application.Caller)
was marked as erroneous, but I can't tell why it's not working for the other squares.
I tried to use this code to change the color of each clicked square.
VBA Code:
Sub MyShape_Click()
On Error Resume Next
Dim sh As Shape
Set sh = ActiveSheet.Shapes(Application.Caller)
If sh.Fill.ForeColor.RGB = RGB(182, 230, 104) Then
sh.Fill.ForeColor.RGB = RGB(255, 255, 163)
ElseIf sh.Fill.ForeColor.RGB = RGB(255, 255, 163) Then
sh.Fill.ForeColor.RGB = RGB(89, 230, 249)
ElseIf sh.Fill.ForeColor.RGB = RGB(89, 230, 249) Then
sh.Fill.ForeColor.RGB = RGB(255, 89, 230)
ElseIf sh.Fill.ForeColor.RGB = RGB(255, 89, 230) Then
sh.Fill.ForeColor.RGB = RGB(237, 125, 49)
ElseIf sh.Fill.ForeColor.RGB = RGB(237, 125, 49) Then
sh.Fill.ForeColor.RGB = RGB(0, 0, 0)
ElseIf sh.Fill.ForeColor.RGB = RGB(0, 0, 0) Then
sh.Fill.ForeColor.RGB = RGB(182, 230, 104)
Else
sh.Fill.ForeColor.RGB = RGB(0, 0, 0)
End If
End Sub
It worked perfectly for the first squares, but the squares that are orange in the image below resulted in an error when clicked.
The line
Set sh = ActiveSheet.Shapes(Application.Caller)
was marked as erroneous, but I can't tell why it's not working for the other squares.