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

Thanks for your input Tom. Sorry I didn't explain myself properly. What I
meant by " Should I have pasted it into an after update event?" was I have
tried it in the Private Sub TextBox27_AfterUpdate() event and it is not
working should I have put it in a different event?

Regards
gregork

"Tom Ogilvy" wrote in message
...
That would be good.

--
Regards,
Tom Ogilvy

gregork wrote in message
...
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.