Color of Buttons

  • Thread starter Thread starter TotallyConfused
  • Start date Start date
T

TotallyConfused

Is there any way you can change the color of buttons on a User Form in Excel?
or a way to highlight the button when using it? If so how? I can't find
anything on how to do this. Can someone please help? Thank you in advance
for any help you can provide.
 
If the button is from the Control Toolbox, you can change the color by
opening the properties menu and using the Backcolor for the button face color
and Forecolor for the caption color.
 
I see that you have answers to actually set the color in properties but you
also asked 'a way to highlight the button when using it'. The following code
will toggle the background color of the button between red and yellow each
time it is clicked.

Private Sub CommandButton1_Click()
If Me.CommandButton1.BackColor = &HFF& Then 'Red
Me.CommandButton1.BackColor = &HFFFF& 'Yellow
Else
Me.CommandButton1.BackColor = &HFF& 'Red
End If
End Sub

The codes for the color can be obtained from the properties dialog box. When
you select the Palet tab for the color and change the color, you will see the
code appear on the line. If you enter the entire number in VBA with the
leading zeros after the H (Hex) then VBA removes them.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top