View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
gregork gregork is offline
external usenet poster
 
Posts: 102
Default 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