If you are talking about an ActiveX TextBox (either on a UserForm or worksheet), then use this Change event procedure (here I have assumed your TextBox is named TextBox1, change the name as needed)...I have an Excel form. In this form is a permanent text box to add comments. I would like the text box to fill yellow whenever any text/number is typed in it, otherwise it should not be filled.
Private Sub TextBox1_Change()
If Len(TextBox1.Text) Then
TextBox1.BackColor = vbYellow
Else
TextBox1.BackColor = vbWhite
End If
End Sub
It worked for me on an ActiveX TextBox when I tested it prior to posting it. First, I'm guessing you put the TextBox on a worksheet (not a UserForm)... where did you install the code? It needs to go on the worksheet's code module, not a general module (where macros go). The easiest way to open the worksheet's code module is to right-click the worksheet's name tab and click "View Code" on the popup menu that appears. Alternately, you can double-click the TextBox itself while Design Mode is active.I tried this on both an Active X text box and a regular insert text box. Didn't work for either one.
It worked for me on an ActiveX TextBox when I tested it prior to posting it. First, I'm guessing you put the TextBox on a worksheet (not a UserForm)... where did you install the code? It needs to go on the worksheet's code module, not a general module (where macros go). The easiest way to open the worksheet's code module is to right-click the worksheet's name tab and click "View Code" on the popup menu that appears. Alternately, you can double-click the TextBox itself while Design Mode is active.