Textbox font colour change?

T

Tdp

I have a textbox linked to a cell in excel, which is already formatted as
"dd-mmm-yy". How can I also include in the texbox font colour to be the same
as in the cell?

I am using the following code to format the textbox:


If IsDate(FoundCell.Offset(0, 1).Value) Then
Me.TextBox1.Value = Format(FoundCell.Offset(0, 1).Value, "dd-mmm-yy")
 
T

Tdp

Can I include your code with the following or does it have to be a seperate
code?

Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
TextBox1.Value = Format(TextBox2.Value, "dd-mmm-yy")
End Sub
 
J

Joel

..Can be the same . I had the code in a module so I needed the activesheet..
The color will stay even if the text is changed. You only need the color
change in the initialization code. You can also manually change the color if
you don't want it in code. Change the worksheet to design mode by opening
the following toolbar

View - Toolbars - Control Toolbox

Then press the triangle which is a toggle ICON (Design Mode). You then need
to press again to return to operational mode..

Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
TextBox1.Value = Format(TextBox2.Value, "dd-mmm-yy")
TextBox1.ForeColor = 65280
End Sub
 
T

Tdp

Thanks very much.
It seems to but when the colour on the spreadsheet changes to red, the
textbox changes to Green!!
If 65280= Green what would Orange and Red be?
 
J

Joel

Pick your own shades. Go into design mode and press the triangle. Then
press the textbox and select the property icon on the tool bar. Go to
forecolor and select. There is a pullwon menu that will pull up a box where
you can select the color. After you sselect the color the number will be
placed in the property window of the text box. Use the number for your macro.
 

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