LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Change Textbox Backcolor and Forecolor at Runtime

I have a UserForm that contains about 28 TextBoxes. I need to change the Back
and Fore color of the textboxes based on the values inside each textbox.
Below is an example of what I am looking to accomplish:
Private Sub txtbx2_Change()
If txtbx2.Text = "actual" Then
ctl.BackColor = &H8000&
ctl.ForeColor = &HFFFFFF
ElseIf txtbx2.Text = "projected" Then
ctl.BackColor = &H8000&
ctl.ForeColor = &HFFFFFF
End If
End Sub

but I don't want to have to write this code for each and every textbox on
the form. Is there a way to do this within one subroutine?
I am looking for one subrutine that would automatically update the textboxes
once the value in it is change and focus is set to another control on the
form.
 
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 forecolor with code Horatio J. Bilge, Jr. Excel Discussion (Misc queries) 2 November 29th 07 05:24 PM
Fill.backcolor and forecolor do not consistent in Chart and Shapes Cool Sport Excel Programming 1 September 26th 05 05:52 AM
TextBox BackColor Lenny_821[_11_] Excel Programming 6 June 15th 05 06:13 PM
BackColor, Forecolor, Bold, and Font Size for ComboBox in Commandbar SZ Excel Programming 11 January 27th 05 06:41 PM
BackColor, Forecolor, Bold, and Font Size for ComboBox in Commandbar SZ Excel Programming 1 January 24th 05 11:40 AM


All times are GMT +1. The time now is 06:16 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"