How to change textbox color based on value in Excel?
- How To Fill A Textbox With Color In Word 2016 For Mac Download
- How To Fill A Textbox With Color In Word 2016 For Macs
Click “Text Box”, “Check Box”, or “Combo Box” in the Developer tab. This will insert a blank fillable field into your document. The Combo Box option creates something like a drop-down menu. Click the Options icon next to the Combo Box icon to access options to turn you. To add a texture to your document background, switch over to the “Design” tab on Word’s Ribbon, and then click the “Page Color” button. In the dropdown menu, click the “Fill Effects” option. In the Fill Effects window, switch to the “Texture” tab, pick a texture, and then click the “OK” button.
In Excel, we can apply the Conditional Formatting function to change the background color based on cell value, but, in this article, I will talk about how to change textbox color based on cell value or value in textbox.
Change textbox color based on cell value with VBA code
How To Fill A Textbox With Color In Word 2016 For Mac Download
Amazing! Using Efficient Tabs in Excel Like Chrome, Firefox and Safari!
Save 50% of your time, and reduce thousands of mouse clicks for you every day!
Let’s say, if cell value in A1 is greater than cell value in B1, I want the textbox to be filled with red color, on the contrary, the textbox should be filled with yellow color. Please achieve this job with following steps:
1. Insert a textbox by clicking Developer > Insert > Text Box (ActiveX Control), and then draw a textbox, see screenshot:
2. Then right click the textbox, and select View Code from the context menu to open the Microsoft Visual Basic for Applications window, and then replace the original code with the following VBA code into the blank module:
VBA code: Change textbox color based on cell values:
Note: In the above code, TextBox1is the textbox name that you inserted, A1 and B1 are the two cells you want to change textbox color based on, please change them to your need.
3. Then save and close the code window, and exit the Design mode, now, if cell A1 is greater than B1, when you type text in the textbox, it will be filled with red color, and if A1 is less than B1, when entering value in the textbox, it will be filled with yellow color, see screenshot:
Change textbox color based on value in textbox with VBA code
If you want to change the textbox color based on the value in textbox, for example, when value in textbox is between 1 and 10, the textbox’s filled color is red, the textbox color is green if value is between 11 and 20, if is other values, the textbox color is yellow. To deal with this task, please apply the below VBA code.
1. After inserting a textbox, right click it, and select View Code from the context menu to open the Microsoft Visual Basic for Applications window, and then replace the original code with the following VBA code into the blank module:
VBA code: Change textbox color based on value in textbox:
Note: In the above code, Textbox1 is the name of the textbox you are inserted, and you can change the values and background color within the code to your own.
2. Then save and close the code window, and exit the Design Mode, now, if you enter the value between 1 and 10 into the textbox, its background color will become red, the value between 11 and 20, the textbox background color will become green, other values, it will become yellow as following screenshot shown:
Related articles:
The Best Office Productivity Tools
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
- Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
- Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
- Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
- Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
- Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
- Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
- Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
- Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
- More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
or post as a guest, but your post won't be published automatically.
How To Fill A Textbox With Color In Word 2016 For Macs
- To post as a guest, your comment is unpublished.Nevermind, I figured it out. Instead of making the event which triggers the change 'Textbox1_GotFocus()', I made it 'Worksheet_SelectionChange(ByVal Target As Range)'. Now any time the value in one of the cells changes, the textbox color changes automatically.
- To post as a guest, your comment is unpublished.For me, when trying to change the textbox color value based on two cell values, the textbox only updates if you type something into the textbox. I need it to update automatically. Guess I'll just have to learn VBA to figure out why.
- To post as a guest, your comment is unpublished.Can someone provide an example workbook so I can see this working? I keep trying but to no avail. Thanks
Would you like to create a questionnaire, sign-up form, quiz or other type of form that people can fill out on their computer? If so, here are some general instructions on how to create a form using Microsoft Word 2011 or Word 2016 on your Mac. Once you’ve created the form you can distribute it as an email attachment or via a web site. The recipient could then complete the form on his or her computer and return it to you. Here are some pointers to how to create a form using Word 2011 and 2016
By default Word’s Form Control features are hidden. To make them visible you have to enable the Developer tab on the Ribbon. Here’s how to do this:
- Open a new document in Word.
- Click on the Word menu and select Preferences.
- Click the Ribbon button on the bottom row on the right-hand side.
- In the Customize section, scroll through the list and insert a check mark next to Developer.
- Click the OK button.
- Click on the Developer tab on the Ribbon and you’ll see the Form Controls as depicted below.
You can now use these controls in a document. Let’s look at how to use the Text Box, Combo Box and Check Box.
The Text Box lets the form-filler type in their own answer. Click the Text Box option to insert a Text Box into your Word document. Double-click on this Text Box to control its options. For example, you could set a Maximum Length for the recipient’s answer.
The Check Box lets you create a box that can be checked by the form-filler.
The Combo Box lets you enter a list of choices that will appear in a drop-down list. The form-filler can select only one choice. After adding a Combo Box to your Word document, double-click it to be able to enter the choices that you want to offer.
The Protect Form button is very important. After you’ve finished your document click the Protect Form button. This button locks the document so it can’t be edited. In other words, it turns the document into a fillable form. Once you’ve protected the form you’re ready to distribute it to others.
Below is a picture of a sample document which demonstrates the Text Box, Combo Box and Check Box.