Color font red when cursor passes over it

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
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.
 
Upvote 0
Not permanently, just while the cursor hovers over it. (I would like to have the font on my Command button turn red).

Noir
 
Upvote 0
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?
 
Upvote 0
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:

<pre>
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</pre>

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.
 
Upvote 0

Forum statistics

Threads
1,213,510
Messages
6,114,044
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top