How Do you Change The Color Of The CommandButton That You Just Prshed

M

Minitman

Greetings,

I have three CommandButtons. I need to know which one was pushed
last.

Does anyone know what the syntax in VBA is to change the background
color of CommandButton1 to pink and CommandButton2 to light gray?
The help section was rather lacking on details for this question.

Any help would be most appreciated.

TIA

-Minitman
 
P

Peter Andrews

Minitman said:
Greetings,

I have three CommandButtons. I need to know which one was pushed
last.

Does anyone know what the syntax in VBA is to change the background
color of CommandButton1 to pink and CommandButton2 to light gray?
The help section was rather lacking on details for this question.

Any help would be most appreciated.

TIA

-Minitman
The following will set the colour of the button pressed to yellow and the
other two to white.
I'm sure that you will be able to do what you want with a little playing.

Private Sub CommandButton1_Click()
CommandButton1.BackColor = RGB(255, 255, 0)
CommandButton2.BackColor = RGB(255, 255, 255)
CommandButton3.BackColor = RGB(255, 255, 255)
End Sub

Private Sub CommandButton2_Click()
CommandButton2.BackColor = RGB(255, 255, 0)
CommandButton3.BackColor = RGB(255, 255, 255)
CommandButton1.BackColor = RGB(255, 255, 255)
End Sub

Private Sub CommandButton3_Click()
CommandButton3.BackColor = RGB(255, 255, 0)
CommandButton2.BackColor = RGB(255, 255, 255)
CommandButton1.BackColor = RGB(255, 255, 255)
End Sub
 

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

Top