Change Button Object Background Color & Font Color

discodavenyc1

New Member
Joined
Feb 23, 2007
Messages
6
Hello All

I have the following code and I'd like to change the font color and background color of these buttons. I can't seem to find the proper code.
Please help. Thanks


Sub CreateButtons()

Dim x As Integer, cell As Range, btn As Object

For x = 10 To 20
For i = 1 To 3

Set cell = Cells(x, i)

Randomize
RandomString = RandString(20)
cell.Value = RandomString
Set btn = ActiveSheet.Buttons.Add(cell.Left, cell.Top, cell.Width, cell.Height)

With btn
.Caption = IIf(i = 1, "up", IIf(i = 2, "down", IIf(i = 3, "in", "")))
.Name = RandomString
'.BackColor = 65535 <--- THIS IS THE ROW RETURNING AN ERROR
.OnAction = "ProcessAction"
End With

Next i

Next x
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Buttons from the Forms toolBox are not able to change there defaulted color.
Just the activeX controls you can change the properties.
 
Upvote 0
Rather than using a form control button why not use a shape? You can change the colours on them quite happily.
 
Upvote 0

Forum statistics

Threads
1,223,981
Messages
6,175,775
Members
452,668
Latest member
mrider123

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