ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   TextBox Color Change (https://www.excelbanter.com/excel-programming/332264-textbox-color-change.html)

Lenny_821[_16_]

TextBox Color Change
 

Hi All,

I want to make my TextBoxes a little more fancy.

What code is best to use when I move my mouse over the TextBox - i
changes color - and when the mouse moves off it changes back to th
original color?

I have tried the Class Module, but I somehow can't figure it out.

Hope you got the anwser:):)

Lenn

--
Lenny_82
-----------------------------------------------------------------------
Lenny_821's Profile: http://www.excelforum.com/member.php...fo&userid=1517
View this thread: http://www.excelforum.com/showthread.php?threadid=38048


Roman[_4_]

TextBox Color Change
 
Hi Lenny,
I hope you are talking about Userform textboxes. Then you can use this
in the Form code:

Private Sub TextBox1_MouseMove(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
If UserForm1.TextBox1.Tag = 0 Then
UserForm1.TextBox1.BackColor = &H80FF& 'the changed color
UserForm1.TextBox1.Tag = 1
End If

End Sub
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
If UserForm1.TextBox1.Tag = 1 Then
UserForm1.TextBox1.BackColor = &HFFFFFF 'the regular color
UserForm1.TextBox1.Tag = 0
End If
End Sub

If you want to change color of the Textbox from Drawing Toolbar then I
canīt help you.


Roman[_4_]

TextBox Color Change
 
Hi Lenny,
I forgot one thing:
set the textbox tag to 0 before you run the code.


Lenny_821[_17_]

TextBox Color Change
 

Hi Roman,

Thanks for your help:)

Lenny


--
Lenny_821
------------------------------------------------------------------------
Lenny_821's Profile: http://www.excelforum.com/member.php...o&userid=15179
View this thread: http://www.excelforum.com/showthread...hreadid=380489



All times are GMT +1. The time now is 09:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com