View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter Andrews Peter Andrews is offline
external usenet poster
 
Posts: 4
Default How Do you Change The Color Of The CommandButton That You Just Prshed


"Minitman" wrote in message
...
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