Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have 10 ActiveX Control CommandButtons on my Sheet. I want macro in
ActiveX Control CommandButton11 that when I click button then all CommandButtons 1 to 10 should get BackColor in Black and also what should be code that when I click button then only CommandButtons 1 to 4 and 6 to 8 get BackColor in Black. Please can any friend can help |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Give this Click event code for CommandButton11 a try...
Private Sub CommandButton11_Click() Dim X As Long With Worksheets("Sheet3") For X = 1 To 10 If X < 5 Then .OLEObjects("CommandButton" & X).Object.BackColor = vbBlack End If Next End With End Sub Note: If you want to change all the buttons BackColor, then just remove the If..Then and End..If statements. If you want to exclude other buttons for being changed to black, just Or them into the If..Then list along with the X<5 exclusion. -- Rick (MVP - Excel) "K" wrote in message ... I have 10 ActiveX Control CommandButtons on my Sheet. I want macro in ActiveX Control CommandButton11 that when I click button then all CommandButtons 1 to 10 should get BackColor in Black and also what should be code that when I click button then only CommandButtons 1 to 4 and 6 to 8 get BackColor in Black. Please can any friend can help |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Jan 19, 8:11*pm, "Rick Rothstein"
wrote: Give this Click event code for CommandButton11 a try... Private Sub CommandButton11_Click() * Dim X As Long * With Worksheets("Sheet3") * * For X = 1 To 10 * * * If X < 5 Then * * * * .OLEObjects("CommandButton" & X).Object.BackColor = vbBlack * * * End If * * Next * End With End Sub Note: If you want to change all the buttons BackColor, then just remove the If..Then and End..If statements. If you want to exclude other buttons for being changed to black, just Or them into the If..Then list along with the X<5 exclusion. -- Rick (MVP - Excel) "K" wrote in message ... I have 10 ActiveX Control CommandButtons on my Sheet. *I want macro in ActiveX Control CommandButton11 that when I click button then all CommandButtons 1 to 10 should get BackColor in Black and also what should be code that when I click button then only CommandButtons 1 to 4 and 6 to 8 get BackColor in Black. *Please can any friend can help- Hide quoted text - - Show quoted text - Thanks lot Rick. You are genious |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I change text from Black on white to white on black? | New Users to Excel | |||
Make CommandButtons Not Visable With A Macro | Excel Worksheet Functions | |||
Commandbutton backcolor change on event | Excel Programming | |||
Change BackColor | Excel Programming | |||
How do I change all chart colors to black and white? | Charts and Charting in Excel |