Color font red when cursor passes over it
Color font red when cursor passes over it
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 7 of 7

Thread: Color font red when cursor passes over it

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Posts
    362
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    Anyone know how to do this?

    Thx,
    Noir

  2. #2
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    what? Change it permanently red? You would have to set up a loop to check where the cursor is located and change the cell contents accordingly.

  3. #3
    Board Regular
    Join Date
    Mar 2002
    Posts
    362
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Not permanently, just while the cursor hovers over it. (I would like to have the font on my Command button turn red).

    Noir

  4. #4
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Oh, on a command button? That's different then. That might be a bit easier.

    Where is this button? On a worksheet? Userform?

    If it's on a worksheet did you create it using the "Control Toolbox" or the "Forms" menu?

  5. #5
    Board Regular
    Join Date
    Mar 2002
    Posts
    362
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    It is a Worksheet and was created using the Control Toolbox.

  6. #6
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    This is the best I could come up with, I inserted a commandbutton called commanbutton1, change this in the code to whatever the name of your button is:


    Private Sub CommandButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    ' Dim iColour As Long

    With CommandButton1
    '
    ' iColour = &H0&
    .ForeColor = &HFF&
    If X < 5 _
    Or X > .Width - 5 _
    Or Y < 5 _
    Or Y > .Height - 5 Then
    .ForeColor = &H0& 'Assume font colour is originally black
    Exit Sub
    Else
    End If
    End With
    End Sub


    The drawbacks are that if you move the mouse away very quickly, the text will stay red, I used the value 5 to make the box smaller in terms of the colour changing to try to reduce this fast mouse move.

    HTH

    Oh yeah, to insert the code, rightclick on the name tab of the sheet that holds the button and select "View Code", copy and paste this code into the window and change "CommandButton1" to the name of your button, there are only two places in the code where you need to do this.

  7. #7
    Board Regular
    Join Date
    Mar 2002
    Posts
    362
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Thanks for all your hard work Mark!! It worked fine.

    Noir

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com