Unselect Form Buttons

rpaulson

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

Working on a user form
Here is some of my code
Code:
Sub Toggle(Button)
With Button
    If .BackColor = &H8000000F Then
            .BackColor = &H80FF80
            .Font.Bold = True
            .Font.Size = 36
        Else
            .BackColor = &H8000000F
            .Font.Bold = False
            .Font.Size = 18
        End If
End With
End Sub
Private Sub CommandButton1_Click()
    Call Toggle(CommandButton1)
End Sub
Private Sub CommandButton2_Click()
    Call Toggle(CommandButton2)
End Sub
Private Sub CommandButton3_Click()
    Call Toggle(CommandButton3)
End Sub
Private Sub CommandButton4_Click()
    Call Toggle(CommandButton4)
End Sub
Private Sub CommandButton5_Click()
    Call Toggle(CommandButton5)
End Sub

If the user select a button it will toggle the button color between green and gray.

What I would like to do is if the user selects a button (ie CommandButton4) it will turn that button green and turn the res of them gray.

Thanks for taking a look.

Ross
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

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