Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpszClass As String, ByVal lpszTitle As String) As Long
'**Win32 API User Defined Types
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Sub MoveCursorTo(rngTarget As Range)
Dim wks As Worksheet, objCht As ChartObject
Dim lngChtHwnd As Long, lngXLDesk As Long
Dim rctPos As RECT
With rngTarget
Set wks = .Parent
Set objCht = wks.ChartObjects.Add(.Left, .Top, 0, 0)
End With
objCht.Activate
lngXLDesk = FindWindowEx(Application.hwnd, 0&, "XLDESK", vbNullString)
lngChtHwnd = FindWindowEx(lngXLDesk, 0&, "EXCELE", vbNullString)
GetWindowRect lngChtHwnd, rctPos
SetCursorPos rctPos.Left, rctPos.Top
objCht.Delete
End Sub
Sub test()
MoveCursorTo Range("AA17")
End Sub