Tennisguuy
Well-known Member
- Joined
- Oct 17, 2007
- Messages
- 564
- Office Version
- 2016
- Platform
- Windows
I have a worksheet that I would like to program the textbox if the value in cell F32 is greater than or equal to 1,000 and there is no text typed in the textbox meaning its blank and the string value would be 0 I want it to turn red. However if F32 is greater than greater than or equal to 1,000 and the user has entered text in the text box and the string length is great than 25 I want it to turn clear or white. I found some code but not sure how to modify it to fit this situation.
I did the following and this worked perfectly but just don't know how to modify the code for the above. This codes changes the textbox based on the value in the text box.
It said to insert a textbox by clicking the developer tab>insert>text box (activeX control), then draw the text box. Then right click on the textbox and select viewcode and paste the following code.
Private Sub TextBox1_Change()
On Error Resume Next
Select Case TextBox1.Value
Case 1 To 10:
TextBox1.BackColor = vbRed
Case 11 To 20:
TextBox1.BackColor = vbGreen
Case Else:
TextBox1.BackColor = vbYellow
End Select
End Sub
I did all of these steps and it work perfectly but I don't know how to change to code to modify my situation above.
I did the following and this worked perfectly but just don't know how to modify the code for the above. This codes changes the textbox based on the value in the text box.
It said to insert a textbox by clicking the developer tab>insert>text box (activeX control), then draw the text box. Then right click on the textbox and select viewcode and paste the following code.
Private Sub TextBox1_Change()
On Error Resume Next
Select Case TextBox1.Value
Case 1 To 10:
TextBox1.BackColor = vbRed
Case 11 To 20:
TextBox1.BackColor = vbGreen
Case Else:
TextBox1.BackColor = vbYellow
End Select
End Sub
I did all of these steps and it work perfectly but I don't know how to change to code to modify my situation above.