Font colors in textboxes, populate textbox with black and input content to be red font. Input?

OTOTO

Board Regular
Joined
Dec 23, 2013
Messages
209
I have a form which upon initialization it fills with information from a worksheet. The user then makes changes to the information that is in the textboxes as they see fit. The information is then copied to another worksheet for review.
I would like the userform to open with all its comboboxes and text boxes to have black font and if the user wishes to make changes then the changes would be indicated in red font. This way the worksheet for review would show 2 different font colors and the changes to be reviewed would be easy to see.
Anyone have any ideas on how to accomplish this?
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
I have a form which upon initialization it fills with information from a worksheet. The user then makes changes to the information that is in the textboxes as they see fit. The information is then copied to another worksheet for review.
I would like the userform to open with all its comboboxes and text boxes to have black font and if the user wishes to make changes then the changes would be indicated in red font. This way the worksheet for review would show 2 different font colors and the changes to be reviewed would be easy to see.
Anyone have any ideas on how to accomplish this?

This is an excerpt from the VBA help file on TextBoxes.
Formatting applied to any piece of text in a TextBox will affect all text in the control. For example, if you change the font or point size of any character in the control, the change will affect all characters in the control.
 

OTOTO

Board Regular
Joined
Dec 23, 2013
Messages
209
This is an excerpt from the VBA help file on TextBoxes.

Thanks!!! I thought that I had seen something similar to this in another post I found through google searching. My solution has been quite simple. I have entered a code:

Private Sub Me.txtbox1_Change()
txtbox1.ForeColor = 255 'Red
End Sub

making the textboxes forecolor red and then entered code that indicates that if the textbox is equal to the cell which populated it then the text is black.

If Me.txtbox1 = currSheet.Cells(currRow, "F") Then
Me.txtbox1.ForeColor = -2147483640 'Black

In this manner, the cell's text is black until the content is changed in which case the text becomes red. Then in the code to enter the textbox information into the cells in the excel sheet where the textbox content is stored I code:

.Offset(RowCount, 8).Value = Me.txtbox1
If Me.txtbox1.ForeColor = 255 Then .Offset(RowCount, 8).Font.ColorIndex = 3 'Red

Then, only the cells which have had changes result in red font in the sheet.

The problem that I am having is that when the text box is populated from a cell that has Paragraphs (Alt + Enter) the code doesn't recognize that txtbox1 = content of the cell which populated it and the content is red. when the cell which populated the textbox had no paragraphs then the text is recognized as = content of the cell which populated it, and it is black.


Any thoughts on this bug?
 

OTOTO

Board Regular
Joined
Dec 23, 2013
Messages
209
Did you set the textbox to multiline?

I had them as Multiline: False so that users could press enter to add more visible text in the box. Per your thought I switched the property to true but it did not fix the problem, it only showed the problem on one line.

Anyone else?
 

Forum statistics

Threads
1,136,353
Messages
5,675,288
Members
419,559
Latest member
BraytonM

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
Top