Home » excel » excel – how to get the relative position of shapes within a worksheet

excel – how to get the relative position of shapes within a worksheet

Posted by: admin April 23, 2020 Leave a comment

Questions:

If you think of cells, we know logically that Row 2 is higher than row 100.

However If I had two shapes (lets say circles) how do I determine which one is higher than the other, or further left than the rest?

UPDTAE

  • Where is the Object model for all Objects and methods / attributes for things like 1. charts >> The Top left

enter image description here

How to&Answers:

Here is some code to display the row for each Shape:

Sub dural()
    Dim s As Shape, mesage As String
    For Each s In ActiveSheet.Shapes
        mesage = mesage & vbCrLf & s.Name & "---" & s.TopLeftCell.Row
    Next s
    MsgBox mesage
End Sub