View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default Multiple Colour changes on User Form

Trefor,
'----------------
Private Sub Frame1_Click()
Call FixThemColors(Me.Frame1.ActiveControl)
End Sub

Sub FixThemColors(ByRef objBox As MSForms.Control)
If TypeName(objBox) = "TextBox" Then
If objBox.Value = "Completed" Then
objBox.ForeColor = 0
objBox.BackColor = RGB(0, 255, 0)
Else
objBox.ForeColor = RGB(255, 0, 0)
objBox.BackColor = RGB(255, 0, 0)
End If
End If
End Sub
'------------
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Trefor" wrote in message...
On a userform I have a "Frame" containing a bunch of text boxes. If the text
box contains the word "Completed" it changes the text box to Black on Green
other it set the text bov to Red on Red. Below is the Module code I am using,
as it stands I am going to have to code this for each and every text box in
the frame. Is it possible to run a loop of some sort across all text boxes in
the one frame?


If Menu.StatusUnisysComp.Value = "Completed" Then
Menu.StatusUnisysComp.ForeColor = 0
Menu.StatusUnisysComp.BackColor = RGB(0, 255, 0)
Else
Menu.StatusUnisysComp.ForeColor = RGB(255, 0, 0)
Menu.StatusUnisysComp.BackColor = RGB(255, 0, 0)
End If

If Menu.StatusNSR.Value = "Completed" Then
Menu.StatusNSR.ForeColor = 0
Menu.StatusNSR.BackColor = RGB(0, 255, 0)
Else
Menu.StatusNSR.ForeColor = RGB(255, 0, 0)
Menu.StatusNSR.BackColor = RGB(255, 0, 0)
End If

--
Trefor