Function CellPosition(Optional rCell As Range)
Dim PointsPerPixelX As Double, PointsPerPixelY As Double
Dim x As Long, y As Long
Dim rng As Range, bFound As Boolean, Arr(1 To 2)
Application.Volatile
If rCell Is Nothing Then Set rCell = ActiveCell
Set rCell = rCell(1, 1)
PointsPerPixelX = 72 / GetDeviceCaps(GetDC(0), 88)
PointsPerPixelY = 72 / GetDeviceCaps(GetDC(0), 90)
ReleaseDC 0, GetDC(0)
For x = Int(Application.Left / PointsPerPixelX) To Int(Application.Left / PointsPerPixelX + Application.Width / PointsPerPixelX)
For y = Int(Application.Top / PointsPerPixelY) To Int(Application.Top / PointsPerPixelY + Application.Height / PointsPerPixelY)
Set rng = Application.Windows(1).RangeFromPoint(x, y)
If Not (rng Is Nothing) Then
bFound = True
Exit For
End If
Next
If bFound Then Exit For
Next
Arr(1) = x * PointsPerPixelX + (rCell.Left - rng.Left)
Arr(2) = y * PointsPerPixelY + (rCell.Top - rng.Top)
CellPosition = Arr
End Function