Toggle form Button Color

rpaulson

Well-known Member
Joined
Oct 4, 2007
Messages
1,428
Hello all,

I designing a user form for a touch screen monitor.
I have a form with 9 buttons. (CommandButton1 thru 9)
The user will be allows to select as many as they wish before they press the OK button.

I need a way to change color when the user toggles the button on\off.

Thanks for taking a look.

Ross
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
try this

Private Sub NameOfCommandB_Click()

NameOfCommandB.backColor = Hex number

end sub



In the properties Window you can view the Palette with all the colors - take your pick then copy paste the Hex number into your code as above - hope I understood your question
 
Upvote 0
Rasm,

your code changes the background color.
I need some code that will toggle colors when button is pressed\depressed.

Ross
 
Upvote 0
Exactly -

If BackColor=Red then Backcolor = green

is this not what you are looking for? - if not clearify
 
Upvote 0
The light bulb came on

Code:
Private Sub CommandButton1_Click()
    With CommandButton1
        If .BackColor = &H8000000F Then .BackColor = &HC0C0FF Else .BackColor = &H8000000F
    End With
End Sub

Thanks for the help.
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,716
Members
452,939
Latest member
WCrawford

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