View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Command button color

Give code something like this a try...

Dim C As Control
Dim Counter As Long
For Each C In Me.Controls
If TypeOf C Is CommandButton Then
Counter = Counter + 1
C.BackColor = Worksheets(Counter).Tab.Color
End If
Next

--
Rick (MVP - Excel)


"art" wrote in message
...
Hello:

I have a userform with 15 command buttons on it. I want to make the color
of
the command button the same color of the sheet tab. So I have the
following
code:

MyColor = Sheet1.Tab.Color
Me.CommandButton1.BackColor = MyColor

However, since I have 15 buttons, I would like to write a code that will
do
it to all command buttons without having to have to write for each command
button this code. It looks like there must be an easier way with either a
loop, or with...

Please help me.

Thanks