how do i conditional formate a text box

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.
 
E

EricG

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
 
J

Jacob Skaria

Me.TextBox1.BackColor = Range("A1").Interior.Color

If this post helps click Yes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top