Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 67
Default Change colour of font in a textbox?

Hi,
Cell F2 in sheet ("customers") format "dd-mmm-yy" it has a format condition
when the date is less then todays date, the font changes to red.
TextBox18 in userform1 value = cell F2.
How can I make the font in textbox18 change when cell F2 changes?
--
capt
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,344
Default Change colour of font in a textbox?

Hi,

You need to write code for the textbox:

Private Sub UserForm_Initialize()
If [a1] 1 Then
Me.TextBox1.ForeColor = RGB(255, 255, 0)
Else
Me.TextBox1.ForeColor = RGB(0, 255, 0)
End If
End Sub


Here is the Help screen on this topic:

Private Sub UserForm_Initialize()
'Initialize each TextBox with a border style or special effect,
'and foreground and background colors

'TextBox1 initially uses a borderstyle
TextBox1.Text = "BorderStyle-Single"
TextBox1.BorderStyle = fmBorderStyleSingle
TextBox1.BorderColor = RGB(255, 128, 128)
'Color - Salmon
TextBox1.ForeColor = RGB(255, 255, 0)
'Color - Yellow
TextBox1.BackColor = RGB(0, 128, 64)
'Color - Green #2

'TextBoxes 2 through 6 initially use special effects
TextBox2.Text = "Flat"
TextBox2.SpecialEffect = fmSpecialEffectFlat
TextBox2.ForeColor = RGB(64, 0, 0)
'Color - Brown
TextBox2.BackColor = RGB(0, 0, 255)
'Color - Blue

'Ensure the background style for TextBox2 is initially
'opaque.
TextBox2.BackStyle = fmBackStyleOpaque

TextBox3.Text = "Etched"
TextBox3.SpecialEffect = fmSpecialEffectEtched
TextBox3.ForeColor = RGB(128, 0, 255)
'Color - Purple
TextBox3.BackColor = RGB(0, 255, 255)
'Color - Cyan

'Define BorderColor for later use (when borderstyle=fmBorderStyleSingle)
TextBox3.BorderColor = RGB(0, 0, 0)
'Color - Black

TextBox4.Text = "Bump"
TextBox4.SpecialEffect = fmSpecialEffectBump
TextBox4.ForeColor = RGB(255, 0, 255)
'Color - Magenta
TextBox4.BackColor = RGB(0, 0, 100)
'Color - Navy blue

TextBox5.Text = "Raised"
TextBox5.SpecialEffect = fmSpecialEffectRaised
TextBox5.ForeColor = RGB(255, 0, 0)
'Color - Red
TextBox5.BackColor = RGB(128, 128, 128)
'Color - Gray

TextBox6.Text = "Sunken"
TextBox6.SpecialEffect = fmSpecialEffectSunken
TextBox6.ForeColor = RGB(0, 64, 0)
'Color - Olive
TextBox6.BackColor = RGB(0, 255, 0)
'Color - Green #1

ToggleButton1.Caption = "Swap styles"
ToggleButton2.Caption = "Transparent/Opaque " _
& "background"
End Sub

Private Sub ToggleButton1_Click()

'Swap borders between TextBox1 and TextBox3
If ToggleButton1.Value = True Then
'Change TextBox1 from BorderStyle to Etched
TextBox1.Text = "Etched"
TextBox1.SpecialEffect = fmSpecialEffectEtched

'Change TextBox3 from Etched to BorderStyle
TextBox3.Text = "BorderStyle-Single"
TextBox3.BorderStyle = fmBorderStyleSingle
Else
'Change TextBox1 back to BorderStyle
TextBox1.Text = "BorderStyle-Single"
TextBox1.BorderStyle = fmBorderStyleSingle

'Change TextBox3 back to Etched
TextBox3.Text = "Etched"
TextBox3.SpecialEffect = fmSpecialEffectEtched
End If
End Sub
Private Sub ToggleButton2_Click()
'Set background to Opaque or Transparent
If ToggleButton2.Value = True Then
'Change TextBox2 to a transparent background
TextBox2.BackStyle = fmBackStyleTransparent
Else
'Change TextBox2 back to opaque background
TextBox2.BackStyle = fmBackStyleOpaque
End If
End Sub

--
Thanks,
Shane Devenshire


"capt" wrote:

Hi,
Cell F2 in sheet ("customers") format "dd-mmm-yy" it has a format condition
when the date is less then todays date, the font changes to red.
TextBox18 in userform1 value = cell F2.
How can I make the font in textbox18 change when cell F2 changes?
--
capt

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 67
Default Change colour of font in a textbox?

Thanks SHANE
It works fine.
--
capt


"ShaneDevenshire" wrote:

Hi,

You need to write code for the textbox:

Private Sub UserForm_Initialize()
If [a1] 1 Then
Me.TextBox1.ForeColor = RGB(255, 255, 0)
Else
Me.TextBox1.ForeColor = RGB(0, 255, 0)
End If
End Sub


Here is the Help screen on this topic:

Private Sub UserForm_Initialize()
'Initialize each TextBox with a border style or special effect,
'and foreground and background colors

'TextBox1 initially uses a borderstyle
TextBox1.Text = "BorderStyle-Single"
TextBox1.BorderStyle = fmBorderStyleSingle
TextBox1.BorderColor = RGB(255, 128, 128)
'Color - Salmon
TextBox1.ForeColor = RGB(255, 255, 0)
'Color - Yellow
TextBox1.BackColor = RGB(0, 128, 64)
'Color - Green #2

'TextBoxes 2 through 6 initially use special effects
TextBox2.Text = "Flat"
TextBox2.SpecialEffect = fmSpecialEffectFlat
TextBox2.ForeColor = RGB(64, 0, 0)
'Color - Brown
TextBox2.BackColor = RGB(0, 0, 255)
'Color - Blue

'Ensure the background style for TextBox2 is initially
'opaque.
TextBox2.BackStyle = fmBackStyleOpaque

TextBox3.Text = "Etched"
TextBox3.SpecialEffect = fmSpecialEffectEtched
TextBox3.ForeColor = RGB(128, 0, 255)
'Color - Purple
TextBox3.BackColor = RGB(0, 255, 255)
'Color - Cyan

'Define BorderColor for later use (when borderstyle=fmBorderStyleSingle)
TextBox3.BorderColor = RGB(0, 0, 0)
'Color - Black

TextBox4.Text = "Bump"
TextBox4.SpecialEffect = fmSpecialEffectBump
TextBox4.ForeColor = RGB(255, 0, 255)
'Color - Magenta
TextBox4.BackColor = RGB(0, 0, 100)
'Color - Navy blue

TextBox5.Text = "Raised"
TextBox5.SpecialEffect = fmSpecialEffectRaised
TextBox5.ForeColor = RGB(255, 0, 0)
'Color - Red
TextBox5.BackColor = RGB(128, 128, 128)
'Color - Gray

TextBox6.Text = "Sunken"
TextBox6.SpecialEffect = fmSpecialEffectSunken
TextBox6.ForeColor = RGB(0, 64, 0)
'Color - Olive
TextBox6.BackColor = RGB(0, 255, 0)
'Color - Green #1

ToggleButton1.Caption = "Swap styles"
ToggleButton2.Caption = "Transparent/Opaque " _
& "background"
End Sub

Private Sub ToggleButton1_Click()

'Swap borders between TextBox1 and TextBox3
If ToggleButton1.Value = True Then
'Change TextBox1 from BorderStyle to Etched
TextBox1.Text = "Etched"
TextBox1.SpecialEffect = fmSpecialEffectEtched

'Change TextBox3 from Etched to BorderStyle
TextBox3.Text = "BorderStyle-Single"
TextBox3.BorderStyle = fmBorderStyleSingle
Else
'Change TextBox1 back to BorderStyle
TextBox1.Text = "BorderStyle-Single"
TextBox1.BorderStyle = fmBorderStyleSingle

'Change TextBox3 back to Etched
TextBox3.Text = "Etched"
TextBox3.SpecialEffect = fmSpecialEffectEtched
End If
End Sub
Private Sub ToggleButton2_Click()
'Set background to Opaque or Transparent
If ToggleButton2.Value = True Then
'Change TextBox2 to a transparent background
TextBox2.BackStyle = fmBackStyleTransparent
Else
'Change TextBox2 back to opaque background
TextBox2.BackStyle = fmBackStyleOpaque
End If
End Sub

--
Thanks,
Shane Devenshire


"capt" wrote:

Hi,
Cell F2 in sheet ("customers") format "dd-mmm-yy" it has a format condition
when the date is less then todays date, the font changes to red.
TextBox18 in userform1 value = cell F2.
How can I make the font in textbox18 change when cell F2 changes?
--
capt

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
Change font colour Min Excel Discussion (Misc queries) 9 February 18th 10 01:50 AM
how to automaticly change colour of font if y becomes < X ogeo Excel Worksheet Functions 1 November 16th 07 05:21 PM
Change font colour Stefi Excel Discussion (Misc queries) 1 March 28th 07 01:54 AM
Change font colour [email protected] Excel Discussion (Misc queries) 3 December 23rd 06 07:07 PM
Change font colour for whole row Saleee Excel Worksheet Functions 2 October 10th 06 06:41 PM


All times are GMT +1. The time now is 08:46 AM.

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

About Us

"It's about Microsoft Excel"