Conditional Formatting a Text Box Excel 2010

Judoman

New Member
Joined
Nov 7, 2014
Messages
31
Office Version
  1. 2016
Platform
  1. Windows
I have a text box in a spreadsheet. Want it to change to yellow whenever any text is typed into the text box.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
If it's an ActiveX control, select Design Mode from the Developer tab, then right click on the text box, choose View Code, then enter this line in the macro template:
Code:
    ActiveSheet.OLEObjects("TextBox1").Object.BackColor = RGB(250, 250, 0)
 
Upvote 0
I entered your string like this:
Sub TextBox1()
ActiveSheet.OLEObjects("TextBox1").Object.BackColor = RGB(250, 250, 0)
End Sub

Got a 'Reference is not valid' message


If it's an ActiveX control, select Design Mode from the Developer tab, then right click on the text box, choose View Code, then enter this line in the macro template:
Code:
    ActiveSheet.OLEObjects("TextBox1").Object.BackColor = RGB(250, 250, 0)
 
Upvote 0
Got Reference Not Valid I thing because I was still in Design mode. However, even out of design mode the box remains white when I type in it.
 
Upvote 0
The whole macro is:
Code:
Private Sub TextBox1_Change()
    ActiveSheet.OLEObjects("TextBox1").Object.BackColor = RGB(250, 250, 0)
End Sub
Note that the subroutine name is "TextBox1_Change" not just "TextBox1". I assume that is the name of your text box, if not, substitute the actual name in both places.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,552
Members
449,088
Latest member
davidcom

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