Make Existing Text Box fill yellow when any text written in it

Judoman

New Member
Joined
Nov 7, 2014
Messages
31
Office Version
  1. 2016
Platform
  1. Windows
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.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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.
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)...
Code:
Private Sub TextBox1_Change()
  If Len(TextBox1.Text) Then
    TextBox1.BackColor = vbYellow
  Else
    TextBox1.BackColor = vbWhite
  End If
End Sub
 
Upvote 0
I tried this on both an Active X text box and a regular insert text box. Didn't work for either one.
 
Upvote 0
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.
 
Upvote 0
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.

Got it to work. Wasn't in design mode.
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,215
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top