View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
gregork gregork is offline
external usenet poster
 
Posts: 102
Default Text box format VBA

Thanks for the reply Harold.Sorry to say I can't get the code to work.
Should I have pasted it into an after update event?
Any suggestions appreciated.

Many thanks
gregork

"Harald Staff" wrote in message
...
"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.