-
Hi Cheryl,
Probably the best way to do this is to store the color value you want in a module level variable so you can use it when you switch back.
If you paste the code below into a new userform with a frame and a commandbutton, you'll see what I mean[VBA]'declare in 'General declarations' so it's available to all the routines
Dim ORIGINAL_COLOR As Long
Private Sub UserForm_Initialize()
CommandButton1.Caption = "New color"
'capture frame's initial back color
ORIGINAL_COLOR = Frame1.BackColor
End Sub
Private Sub CommandButton1_Click()
If CommandButton1.Caption = "New color" Then
Frame1.BackColor = RGB(255, 0, 0)
CommandButton1.Caption = "Old color"
ElseIf CommandButton1.Caption = "Old color" Then
Frame1.BackColor = ORIGINAL_COLOR
CommandButton1.Caption = "New color"
End If
End Sub
[/VBA]
K :-)

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules