How do you track the mouse pointer in Excel
Manage your personal finances in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: How do you track the mouse pointer in Excel

  1. #1
    New Member
    Join Date
    Feb 2002
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    Excel macros do not offer the MouseMove event for Worksheets (it's only available over controls).

    Any idea how to detect MouseMove some other way?

    Many thanks!
    (PS: Using Excel 97 & 2000)

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    2,936
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    You can use a simple Windows API call. Insert this code in a standard module and give it a go.

    Code:
    Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Public Type POINTAPI
            x As Long
            y As Long
    End Type
    
    
    Sub GetTheCursorPosition()
    Dim lngCurPos As POINTAPI
    
    Do
        GetCursorPos lngCurPos
        Cells(1, 1).Value = "X = " & lngCurPos.x
        Cells(2, 1).Value = "Y = " & lngCurPos.y
        DoEvents
    Loop
    
    End Sub
    HTH,
    D

  3. #3
    New Member
    Join Date
    Feb 2002
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Nice one, thank you.

    I don't suppose you'd know how to detect when the mouse is over specific cells would you?!

  4. #4
    New Member
    Join Date
    Oct 2011
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: How do you track the mouse pointer in Excel

      
    This is exactly what I was looking for also. Hope you don't mind I BORROW! this for my little experiment .Thanks a million.

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