ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   TextBox Color Red if Less than 50 (https://www.excelbanter.com/excel-programming/415134-textbox-color-red-if-less-than-50-a.html)

Shazi

TextBox Color Red if Less than 50
 
Hi Everyone,

I have a textbox in userform, I want to change the TextColor (interior
color) if the value is less than 50 then it will be Blue. (to show the
quantity is less)

Regards.

Shahzad

GTVT06

TextBox Color Red if Less than 50
 
On Aug 4, 4:12*pm, Shazi wrote:
Hi Everyone,

I have a textbox in userform, I want to change the TextColor (interior
color) if the value is less than 50 then it will be Blue. (to show the
quantity is less)

Regards.

Shahzad

Hello try this

Private Sub TextBox1_Change()
If TextBox1.Value < 50 Then TextBox1.BackColor = &HFF0000 Else
TextBox1.BackColor = &HFFFFFF

End Sub

Rick Rothstein \(MVP - VB\)[_2502_]

TextBox Color Red if Less than 50
 
This way maybe...

Private Sub TextBox1_Change()
If Val(TextBox1.Text) < 50 Then
TextBox1.BackColor = vbRed
Else
TextBox1.BackColor = vbWhite
End If
End Sub

Rick


"Shazi" wrote in message
...
Hi Everyone,

I have a textbox in userform, I want to change the TextColor (interior
color) if the value is less than 50 then it will be Blue. (to show the
quantity is less)

Regards.

Shahzad



GTVT06

TextBox Color Red if Less than 50
 
Sorry, I couldn't tell if you were trying to change the font color or
the text box color. my previous post will change the text box color,
the code below will change the font color.

Private Sub TextBox1_Change()
If TextBox1.Value < 50 Then TextBox1.ForeColor = &HFF0000 Else
TextBox1.ForeColor = &HFFFFFF

End Sub



All times are GMT +1. The time now is 04:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com