Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The code I am using here does highlight the cell under the cursor ( Without
selecting the cell) but has two major problems : 1- It causes too much flickering . 2- If a cell is selected with the Mouse, the selected cell is sometimes Formatted which shouldn't normally happen . Here is the code: Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, _ ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Type POINTAPI x As Long y As Long End Type Dim lngCurPos As POINTAPI Dim TimerOn As Boolean Dim TimerId As Long Dim oldColor As Long Dim R As Range Sub StartTimer() If Not TimerOn Then TimerId = SetTimer(0, 0, 1, AddressOf TimerProc) TimerOn = True Else MsgBox "Timer already On !", vbInformation End If End Sub Sub TimerProc() On Error Resume Next 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 End Sub Public Sub StopTimer() If TimerOn Then KillTimer 0, TimerId TimerOn = False Else MsgBox "Timer already Off", vbInformation End If End Sub I hope someone can improve this code by fixing the 2 mentioned problems or maybe just offer a new solution altogether. Thanks. Jaafar. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to mouse function to highlight the current cell your using. | Excel Discussion (Misc queries) | |||
mouse pointer over cell | Excel Discussion (Misc queries) | |||
mouse pointer | Excel Discussion (Misc queries) | |||
my mouse pointer locks on a cell in excel | Excel Worksheet Functions | |||
Mouse pointer | Excel Programming |