![]() |
How Do you Change The Color Of The CommandButton That You Just Prshed
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 |
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 |
How Do you Change The Color Of The CommandButton That You Just Prshed
Hey Peter,
Thank you, that is exactly what I was looking for. -Minitman On Tue, 05 Oct 2004 16:12:48 GMT, "Peter Andrews" wrote: "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 |
All times are GMT +1. The time now is 01:37 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com