View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
TotallyConfused TotallyConfused is offline
external usenet poster
 
Posts: 144
Default Multipage Buttons??

Thank you this works. I will have to set the multipage with "no Tabs", add
command buttons to change color when I click. However, I have to open the
page. HHow do I write the code to add to the code below to open the page?
Thank you.

"JLGWhiz" wrote:

I would just put the button on the UserForm as a separate control and change
the code as follows:

Private Sub CommandButton1_Click()
Dim cb1 As CommandButton
Set cb1 = Me.CommandButton1
If cb1.BackColor = &H80FF80 Then
cb1.BackColor = &HFFFF80
Else
cb1.BackColor = &H80FF80
End If

'Add additional code here if needed to perform an action.

End Sub

The Me constant refers to the object that holds the code, which in this case
would be the UserForm. It is assumed that you would want the some action to
be performed when the button is clicked so you can add that in beneath the
code to change colors. You can also change the If statement to set some
other criteria to make the color change, I only used the paricular wording
to show how it is done. You can also get different color codes by opening
the properties window for the button (design mode and right click button)
and click on backcolorpalette. Click a color to use then copy the code
from there to the macro. Or you can go through the agony of trying to set
RGB colors.



"TotallyConfused" wrote in
message ...
I am sorry for being stupid with this but I am new to Excel code. If I
create command button from the Control Toolbox do I put this command
button
over one of the tabs? I have over 10 pages in my multipage tool in my
userform. Also for multipage, they are identified as Page1 etc. If I
change the code below to read Page(1) will the code still work? Thank
you.

"JLGWhiz" wrote:

Put a button from Control Toolbox on Sheet1 and put the following code in
the sheet code module.

Private Sub CommandButton1_Click()
Dim cb1 As CommandButton
Set cb1 = Sheets(1).CommandButton1
If cb1.BackColor = &H80FF80 Then
Sheets(1).CommandButton1.BackColor = &HFFFF80
Else
Sheets(1).CommandButton1.BackColor = &H80FF80
End If
End Sub


Be sure you are not in design mode and the button should change from
green
to blue and vice versa.


"TotallyConfused" wrote in
message ...
I am wondering if you can make the buttons/tabs on a multipage in an
Excel
Userform different color when you click on it???? Can someone please
help
me
with this? Thank you very much.