Latitude And Longitude Of Active Cell

Jaye7

Well-known Member
Joined
Jul 7, 2010
Messages
1,060
Does anyone have a vba script to list the co-ordinates (latitude and longitude) of the activecell so that I can move the cursor to that position.

I have the following script which lists the cursor position, but would like the cell position co-ordinates.

Code:
 Dim MyPointAPI As POINTAPI
Private Type POINTAPI
  x As Long
  Y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal Y As Long) As Long
 
Public Sub MouseCursorGetOurXY()
        'Following functions will need the above lib "user32" declarations
    l = GetCursorPos(MyPointAPI) 'get our cursor position first
    MsgBox CStr(MyPointAPI.x) & ", " & CStr(MyPointAPI.Y) 'displays cursor X Y coordinates
End Sub
Code:
Sub Worksheet_SelectionChange(ByVal Target As Range)
MouseCursorGetOurXY
end sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hi Jaye7,

You can get the coordinate in points for the Top Left corner of the ActiveCell using
.Top and .Left Properties.

Code:
With ActiveCell
    MsgBox "Top: " & .Top & vbCr & "Left: " & .Left
End With
 
Upvote 0

Forum statistics

Threads
1,215,046
Messages
6,122,854
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top