Text format - setting text colour with code

N

NDBC

I'm on the home straight now (I think). What I would like to do is make text
in a text box go red if a certain condition is met. ie.

If rider1.value >700 Then

rider1.font = colour red (or whatever the correct code for this is)

Thanks
 
J

JLatham

If rider1 > 700 Then
rider1.Font.ColorIndex = 3
Else
rider1.Font.ColorIndex = xlAutomatic
End If

But you can accomplish the same thing using conditional formatting, without
any code at all. Format --> Cells -->Conditional Format
Then set up for cell value > 700 and set the font color.
 
N

NDBC

Thanks for the reply. Does conditional formatting work in text boxes on user
forms.
 
J

JLatham

Nope, that code won't work with a textbox - it works with a cell. I didn't
realize we were talking about text boxes, since textboxes don't have numeric
values that you can test, they contain text/words/numers that are text and
not really numbers.

I've got to rush off right now, but I'll work up something for the textbox
shortly - where did the textbox come from? The "Controls Toolbox" group or
the "Forms" group.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top