Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Change BackColor of CommandButtons in Black by Macro

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Change BackColor of CommandButtons in Black by Macro

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Change BackColor of CommandButtons in Black by Macro

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I change text from Black on white to white on black? Joe G. New Users to Excel 1 December 19th 08 09:43 PM
Make CommandButtons Not Visable With A Macro Minitman Excel Worksheet Functions 7 April 1st 08 05:55 AM
Commandbutton backcolor change on event peter.thompson[_3_] Excel Programming 3 December 17th 05 10:10 AM
Change BackColor Steve Excel Programming 1 July 11th 05 04:09 PM
How do I change all chart colors to black and white? deedee3 Charts and Charting in Excel 1 March 17th 05 04:53 AM


All times are GMT +1. The time now is 02:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"