Active X Button - need to change background color

Jenny McMillan

New Member
Joined
Jul 13, 2016
Messages
2
Here is the code I have for the Macro, but I am not able to figure out how to change the color of the botton on the worksheet. Can anyone help me fix my code. I am new to Excel:

Sub Macro1()
'
' Macro1 Macro
'

'

Application.ScreenUpdating = False
Sheets("Template-Contact Log").Visible = True
Sheets("Template-Contact Log").Select
Sheets("Template-Contact Log").Copy Before:=Sheets(4)
Sheets("Template-Contact Log").Visible = False
Sheets("Template-Contact Log (2)").Select
Range("E1").Value = Sheets("CIS & W9 Site Information").Range("G1").<wbr>Value
Sheets("Template-Contact Log (2)").Name = Sheets("CIS & W9 Site Information").Range("G1").<wbr>Value



End Sub
Sub Macro2()
'
' Macro2 Macro
'

'

Sheets("Template-Contact Log (2)").Name = "2 - Dr. Peter Datlowe"
End Sub


Thanks - Jenny
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Following code sets the color of ActiveX button named "CommandButton1" on the sheet "Sheet1" to red, text color to white and style to Bold.

Code:
Sheets("Sheet1").CommandButton1.BackColor = RGB(255, 0, 0)
Sheets("Sheet1").CommandButton1.ForeColor = RGB(255, 255, 255)
Sheets("Sheet1").CommandButton1.Font.Bold = True
 
Last edited:
Upvote 0
Hi,

Thanks for the coding, I am sorry, but I added it right before the first line starting with Sheets, and I got a run time error. What did I do wrong? Thanks for the help.
 
Upvote 0
What is the error message?

Maybe your ActiveX button is named something else. Go to Developer tab, click on Design Mode, then select the ActiveX button that you want to change and click Properties button in ribbon. What is the value assigned to (Name) property in the Properties pop-up?
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,967
Members
452,371
Latest member
Frana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top