Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 204
Default Text format - setting text colour with code

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default Text format - setting text colour with code

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.

"NDBC" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 204
Default Text format - setting text colour with code

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

"JLatham" wrote:

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.

"NDBC" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 204
Default Text format - setting text colour with code

JL

Just tried that and am getting an error. I clicked on the textbox object and
the name is rider1 (Rider1 TextBox at top). I want the text in this box to be
red based on the value of the text/number entered in the box. I think I must
be refering to the textbox incorrectly. Any ideas.


"JLatham" wrote:

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.

"NDBC" wrote:

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

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default Text format - setting text colour with code

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.

"NDBC" wrote:

JL

Just tried that and am getting an error. I clicked on the textbox object and
the name is rider1 (Rider1 TextBox at top). I want the text in this box to be
red based on the value of the text/number entered in the box. I think I must
be refering to the textbox incorrectly. Any ideas.


"JLatham" wrote:

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.

"NDBC" wrote:

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



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Text format - setting text colour with code

Try

Me.TextBox1.ForeColor = vbRed

If this post helps click Yes
---------------
Jacob Skaria


"NDBC" wrote:

JL

Just tried that and am getting an error. I clicked on the textbox object and
the name is rider1 (Rider1 TextBox at top). I want the text in this box to be
red based on the value of the text/number entered in the box. I think I must
be refering to the textbox incorrectly. Any ideas.


"JLatham" wrote:

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.

"NDBC" wrote:

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

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 204
Default Text format - setting text colour with code

Thank you, it worked without the me. at the start.


"Jacob Skaria" wrote:

Try

Me.TextBox1.ForeColor = vbRed

If this post helps click Yes
---------------
Jacob Skaria


"NDBC" wrote:

JL

Just tried that and am getting an error. I clicked on the textbox object and
the name is rider1 (Rider1 TextBox at top). I want the text in this box to be
red based on the value of the text/number entered in the box. I think I must
be refering to the textbox incorrectly. Any ideas.


"JLatham" wrote:

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.

"NDBC" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional Formatting - Code to colour 3+ text values differently AK9955 Excel Discussion (Misc queries) 3 November 9th 09 06:11 PM
remove text with format code for phone numbers Jan Excel Discussion (Misc queries) 4 November 12th 08 02:03 PM
Conditionl format a cell to change text colour PAULANDBEX24 Excel Discussion (Misc queries) 7 October 7th 08 09:05 AM
Conditional Format to Retain Text Colour from a List on another Sh Dasha New Users to Excel 9 November 5th 07 10:11 PM
Can i format (colour) selective text in a cell using excel2000? Bretter99 Excel Discussion (Misc queries) 3 July 16th 07 07:08 PM


All times are GMT +1. The time now is 11:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"