keep button colour same

redspanna

Well-known Member
Joined
Jul 27, 2005
Messages
1,602
Office Version
  1. 365
Platform
  1. Windows
Hi all

I have this simpe code that will change the colour of a Rounded Rectangle button from white to green once selected....

Code:
Sub RoudedRectangle13_Click()
Application.ScreenUpdating = False
ActiveSheet.Shapes("Rounded Rectangle 13").Fill.ForeColor.RGB = RGB(153, 204, 0)
ActiveSheet.Shapes("Rounded Rectangle 14").Fill.ForeColor.RGB = RGB(255, 255, 255)
ActiveSheet.Shapes("Rounded Rectangle 15").Fill.ForeColor.RGB = RGB(255, 255, 255)

End Sub

Sub RoudedRectangle14_Click()
Application.ScreenUpdating = False
ActiveSheet.Shapes("Rounded Rectangle 13").Fill.ForeColor.RGB = RGB(255, 255, 255)
ActiveSheet.Shapes("Rounded Rectangle 14").Fill.ForeColor.RGB = RGB(153, 204, 0)
ActiveSheet.Shapes("Rounded Rectangle 15").Fill.ForeColor.RGB = RGB(255, 255, 255)


End Sub
Sub RoudedRectangle15_Click()
Application.ScreenUpdating = False
ActiveSheet.Shapes("Rounded Rectangle 13").Fill.ForeColor.RGB = RGB(255, 255, 255)
ActiveSheet.Shapes("Rounded Rectangle 14").Fill.ForeColor.RGB = RGB(255, 255, 255)
ActiveSheet.Shapes("Rounded Rectangle 15").Fill.ForeColor.RGB = RGB(153, 204, 0)


End Sub

Can this code be changed so that if Rounded Rectangle 13 is selected it remains green even if Rounded Rectangle 14 or 15 is also selected and same for other two buttons

So result is whatever button or buttons are selected they remain green and NOT changed back to white if another button is selected.

Thanks in advance
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Assign this macro to all of the shapes.

Code:
Sub AnyRoudedRectangle_Click()
    Application.ScreenUpdating = False
    With ActiveSheet.Shapes(Application.Caller).Fill.ForeColor
        If .RGB = vbWhite Then
            .RGB = RGB(153, 204, 0)
        Else
            .RGB = vbWhite
        End If
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,429
Messages
6,124,839
Members
449,193
Latest member
MikeVol

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top