how do i conditional formate a text box

  • Thread starter Thread starter TML
  • Start date Start date
T

TML

I have some text boxes set to display the contents of a cell. that cell has
conditional formating to change color when a certain value is entered. I also
want the text box fill color to change with that value.
 
Here is a simple version that toggles the background and foreground colors of
a textbox if the textbox has a certain value in it:

Private Sub TextBox1_Change()
If Me.TextBox1.Value = "Y" Then
Me.TextBox1.ForeColor = RGB(250, 225, 122) ' Font color
Me.TextBox1.BackColor = RGB(150, 125, 222) ' Background color
Else
Me.TextBox1.ForeColor = RGB(0, 0, 0) ' Font color
Me.TextBox1.BackColor = RGB(255, 255, 255) ' Background color
End If
End Sub
 
Back
Top