+ Reply to Thread
Results 1 to 13 of 13

Cell Address of Mouse Pointer

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-04-2011
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2007
    Posts
    109

    Cell Address of Mouse Pointer

    I have a coworker who claims that in an older version of Excel (currently 2007), she was able to identify the location of the mouse pointer (cell address) as she moved it around the worksheet. I don't think she means a mouseover description displaying the cell address, but rulers along the top and sides that would have indicators which you could easily identify the row/column without having to click the cell. Does anybody have any insight into how to get these rulers to display?
    Last edited by Dionysos; 03-01-2012 at 10:00 AM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,962

    Re: Cell Address of Mouse Pointer

    I know you can do that in powerpoint, but i have nevr seen that in any version of excel
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Contributor
    Join Date
    08-04-2011
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2007
    Posts
    109

    Re: Cell Address of Mouse Pointer

    Quote Originally Posted by FDibbins View Post
    I know you can do that in powerpoint, but i have nevr seen that in any version of excel
    I checked out this functionality in PowerPoint and it looks to be exactly what she described. I'm wondering if she has her applications mixed up because I certainly have never used, or seen, a feature like this in Excel.

    p.s. I tried the VBA route and I couldn't get the code to work, plus she want's this functionality to work universally across all spreadsheets.

  4. #4
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: Cell Address of Mouse Pointer

    cells in PowerPoint?

    Intresting

  5. #5
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: Cell Address of Mouse Pointer

    Its API code credit to the author -- have fun

    
    In a standard module:
    
    Option Explicit
    
    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
    Public oldColor As Long
    Dim newRange As Range
    Dim oldRange As Range
    
    Sub StartTimer()
    If Not TimerOn Then
    TimerId = SetTimer(0, 0, 0.01, AddressOf TimerProc)
    TimerOn = True
    Else
    MsgBox "Timer already On !", vbInformation
    End If
    End Sub
    
    Sub TimerProc()
    On Error Resume Next
    GetCursorPos lngCurPos
    Set newRange = ActiveWindow.RangeFromPoint(lngCurPos.x, lngCurPos.Y)
    If newRange.Address <> oldRange.Address Then Range("A1").Value = newRange.Address
    Set oldRange = newRange
    End Sub
    
    Sub StopTimer()
    If TimerOn Then
    KillTimer 0, TimerId
    TimerOn = False
    Else
    MsgBox "Timer already Off", vbInformation
    End If
    End Sub
    
    
    In the worksheet module:
    
    Option Explicit
    
    Dim TrgtColor As Long
    Dim oldTarget As Range
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    Target.Interior.ColorIndex = TrgtColor
    End Sub
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Set oldTarget = Target
    TrgtColor = oldColor
    End Sub
    To activate the code, run the "StartTimer" macro and to stop it, run the "StopTimer" macro.

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,962

    Re: Cell Address of Mouse Pointer

    to jack....i didnt mean there are cells in PP, just that you can set PP up to show where the pointer is in the top and bottom margins

  7. #7
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: Cell Address of Mouse Pointer

    Maybe replace this bit code as makes easier to read in cell A1
    Sub TimerProc()
    On Error Resume Next
    GetCursorPos lngCurPos
    Set newRange = ActiveWindow.RangeFromPoint(lngCurPos.x, lngCurPos.Y)
    If newRange.Address <> oldRange.Address Then Range("A1").Value = newRange.Address(False, False)
    '\\ jiuk - note used false / false to take away the default anchors 
    Set oldRange = newRange
    End Sub

  8. #8
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: Cell Address of Mouse Pointer

    Or you could change destination cell A1 to status bar read out and cancel on exit ie

    Use this code to take control of the status bar
    Application.StatusBar =
    And add this code to cancel on exit or stop which will give control of the statusbar back to the programme
     Application.StatusBar = False

  9. #9
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: Cell Address of Mouse Pointer

    Code work perfectly and shows the mouse CELLs lcation in cell A1....

    This is a good start, why does the code not work for you, follow my instuctions as to where to put the codes

    ie some in the standard module, some in the worksheet module

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Cell Address of Mouse Pointer

    Maybe this. It highlights the row, but could easily be adapted
    Attached Files Attached Files
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  11. #11
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: Cell Address of Mouse Pointer

    Ermm re RE tested and yes the code works on all worksheets in the workbook and reports to cell A1 each times

    Not sure what You are doing incorectly

  12. #12
    Forum Contributor
    Join Date
    08-04-2011
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2007
    Posts
    109

    Re: Cell Address of Mouse Pointer

    Jack,

    Code looks good. For whatever reason the font color in A1 matched the background and therefore was not apparent. I think this is good if A1 is always viewable. I may be able to work with royUK's code. Thanks for all the contributions. I'll mark this solved.

  13. #13
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: Cell Address of Mouse Pointer

    Yes agreed so see the post above re status bar ... that would work even better

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1