Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Text box format VBA
Hi All,
Can you conditionally format a text box back colour on a user form? For instance if the value in textbox1 was not in between (sheet1 cell= C1 and sheet1 cell= C2) make the textbox1 back colour red. How would you do this? Regards gregork |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Text box format VBA
gregork,
In the TextBox AfterUpdate Event. Private Sub TextBox1_AfterUpdate() If Val(TextBox1.Value) Worksheets("Sheet1").Range("C1").Value And _ Val(TextBox1.Value) < Worksheets("Sheet1").Range("C2").Value Then TextBox1.BackColor = vbRed Else TextBox1.BackColor = vbWhite End If End Sub John "gregork" wrote in message ... Hi All, Can you conditionally format a text box back colour on a user form? For instance if the value in textbox1 was not in between (sheet1 cell= C1 and sheet1 cell= C2) make the textbox1 back colour red. How would you do this? Regards gregork |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Text box format VBA
Perfect, many thanks John.
Kind Regards gregork "John Wilson" wrote in message ... gregork, In the TextBox AfterUpdate Event. Private Sub TextBox1_AfterUpdate() If Val(TextBox1.Value) Worksheets("Sheet1").Range("C1").Value And _ Val(TextBox1.Value) < Worksheets("Sheet1").Range("C2").Value Then TextBox1.BackColor = vbRed Else TextBox1.BackColor = vbWhite End If End Sub John "gregork" wrote in message ... Hi All, Can you conditionally format a text box back colour on a user form? For instance if the value in textbox1 was not in between (sheet1 cell= C1 and sheet1 cell= C2) make the textbox1 back colour red. How would you do this? Regards gregork |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Text box format VBA
gregork,
Happy to have been a help. Thanks for the reply. John "gregork" wrote in message ... Perfect, many thanks John. Kind Regards gregork "John Wilson" wrote in message ... gregork, In the TextBox AfterUpdate Event. Private Sub TextBox1_AfterUpdate() If Val(TextBox1.Value) Worksheets("Sheet1").Range("C1").Value And _ Val(TextBox1.Value) < Worksheets("Sheet1").Range("C2").Value Then TextBox1.BackColor = vbRed Else TextBox1.BackColor = vbWhite End If End Sub John "gregork" wrote in message ... Hi All, Can you conditionally format a text box back colour on a user form? For instance if the value in textbox1 was not in between (sheet1 cell= C1 and sheet1 cell= C2) make the textbox1 back colour red. How would you do this? Regards gregork |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Text box format VBA
John I hope your still out there. I'm having trouble with another formatting
problem. I want to format back colour based on text in a textbox. i.e. If textbox27 text="fail" then TextBox27.BackColor = &HC0C0FF. I've tried variations on the code you gave me but I can't quite make it happen. Kind Regards gregork "John Wilson" wrote in message ... gregork, Happy to have been a help. Thanks for the reply. John "gregork" wrote in message ... Perfect, many thanks John. Kind Regards gregork "John Wilson" wrote in message ... gregork, In the TextBox AfterUpdate Event. Private Sub TextBox1_AfterUpdate() If Val(TextBox1.Value) Worksheets("Sheet1").Range("C1").Value And _ Val(TextBox1.Value) < Worksheets("Sheet1").Range("C2").Value Then TextBox1.BackColor = vbRed Else TextBox1.BackColor = vbWhite End If End Sub John "gregork" wrote in message ... Hi All, Can you conditionally format a text box back colour on a user form? For instance if the value in textbox1 was not in between (sheet1 cell= C1 and sheet1 cell= C2) make the textbox1 back colour red. How would you do this? Regards gregork |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Text box format VBA
"gregork" wrote in message
... I want to format back colour based on text in a textbox. i.e. If textbox27 text="fail" then TextBox27.BackColor = &HC0C0FF. You are very close: If TextBox27.Text = "fail" Then TextBox27.BackColor = "&HC0C0FF" Else TextBox27.BackColor = "&HFFFFFF" End If But consider uppercase, mixed case, part entries, trailing spaces... If InStr(Trim$(LCase$(TextBox27.Text)), "fail") 0 Then reacts also on entry " You FAILED madam" -- HTH. Best wishes Harald Followup to newsgroup only please. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
from date format convert to text format is wrong | Excel Discussion (Misc queries) | |||
Need help with converting CUSTOM format/TEXT format to DATE format | Excel Worksheet Functions | |||
Change Date Format to Specific Text Format When Copying | Excel Discussion (Misc queries) | |||
Change number (in text format) to numeric format | Excel Discussion (Misc queries) | |||
how to format excel format to text format with separator "|" in s. | New Users to Excel |