Jaafar Tribak
Well-known Member
- Joined
- Dec 5, 2002
- Messages
- 9,806
- Office Version
- 2016
- Platform
- Windows
Hi,
I used the rather overlooked property ( RangeFromPoint) to find a solution to the problem Highlighting cell under mouse pointer)raised here : http://www.mrexcel.com/board2/viewtopic.php?t=90381&highlight=mouse
...Can't believe I missed this handy property which makes the whole thing so easy.
I have tried the code below and it worked quite nicely for me apart from the mouse flickering which I hope I could get rid of.
Hey Tom, is the Beers prize still on ?
Regards.
I used the rather overlooked property ( RangeFromPoint) to find a solution to the problem Highlighting cell under mouse pointer)raised here : http://www.mrexcel.com/board2/viewtopic.php?t=90381&highlight=mouse
...Can't believe I missed this handy property which makes the whole thing so easy.
I have tried the code below and it worked quite nicely for me apart from the mouse flickering which I hope I could get rid of.
Code:
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Type POINTAPI
x As Long
y As Long
End Type
Dim lngCurPos As POINTAPI
Dim Cancel As Boolean
Dim R As Range
Dim oldColor As Long
Public Sub ChangeCellColor()
Cancel = False
On Error Resume Next
Do Until Cancel = True
With ActiveWindow
If Not R Is .RangeFromPoint(lngCurPos.x, lngCurPos.y) Then
R.Interior.ColorIndex = oldColor
End If
GetCursorPos lngCurPos
Set R = .RangeFromPoint(lngCurPos.x, lngCurPos.y)
oldColor = R.Interior.ColorIndex
.RangeFromPoint(lngCurPos.x, lngCurPos.y).Interior.ColorIndex = 3 'Red
End With
DoEvents
Loop
End Sub
Public Sub CancelProcedure()
Cancel = True
Set R = Nothing
End Sub
Hey Tom, is the Beers prize still on ?
Regards.