View Full Version : Active Tab change Backcolor
Emoncada
01-06-2008, 08:46 PM
I have a userform that I would like to have the txtbox or combobox when active to have a red backcolor so the user knows where they are. How can I do that without having to add code to all the txtboxes and cmbboxes?
Emoncada
01-07-2008, 09:12 AM
If possible have it change red when entered and then white when after exiting.
It's harder than you might think unless I've missed something about assigning event sinks to the MSForms.Control object. There is a method shown by Colo here (http://www.mrexcel.com/archive2/59800/69331.htm).
Bob Phillips
01-07-2008, 09:47 AM
Private Sub TextBox1_Enter()
Me.TextBox1.BackColor = RGB(255, 0, 0)
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Me.TextBox1.BackColor = RGB(255, 255, 255)
End Sub
How can I do that without having to add code to all the txtboxes and cmbboxes?
is the tricky bit. :) Googling in fact located a post by you (xld) elsewhere pointing out that the Enter and Exit events are inherited from the container and therefore not exposed to the event sink (at least I think that's what you said!).
Bob Phillips
01-07-2008, 10:11 AM
Yeah, shame, but that is how it is.
And there's not even a ChangeControl method of the userform to use instead.
Emoncada
01-07-2008, 11:32 AM
Yeah well I will use Xld's method I will do it for all of them manually. It works great. How can I get a list of all the color codes for excel. Like for Lite blue?
Bob Phillips
01-07-2008, 02:26 PM
Dim i as long
For i = 1 To 56
cells(i,"A").value = i
Cells(i,"B").Interior.Colorindex = i
Next i
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.