Text Box Color

SAT-65

Board Regular
Joined
Feb 10, 2008
Messages
69
Is there a way to get a text box to change it's background color depending on a cell value?
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hello,

Yes it is possible though the use of VBA. I can not think how to acomplish this with Conditional Format or formula.

Right click the sheet tab >>
Veiw Code>>
paste in:
******************************************

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_Change(<SPAN style="color:#00007F">ByVal</SPAN> Target <SPAN style="color:#00007F">As</SPAN> Range)<br><br>    <SPAN style="color:#00007F">If</SPAN> Range("A1").Value >= 10 <SPAN style="color:#00007F">Then</SPAN><br>        ActiveSheet.Shapes("TextBox 1").Fill.ForeColor.RGB = RGB(255, 0, 0)<br>    <SPAN style="color:#00007F">Else</SPAN><br>        ActiveSheet.Shapes("TextBox 1").Fill.ForeColor.RGB = RGB(255, 255, 255)<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>        <br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

******************************************


Modify "Text Box 1" to your text box name. (this uses a textbox from the insert menu in Excel 2007.)
Modify "A1" to your cell reference
Modify >= 10 to meet your criteria
Modify RGB(255,0,0) to your color choice

(The code turns red when value in cell A1 is greater than or equal to 10
if not the textbox color is white.)



Close the VBEditor>>
change any cell on your sheet.
 
Upvote 0

Forum statistics

Threads
1,224,617
Messages
6,179,914
Members
452,949
Latest member
beartooth91

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