Created
January 9, 2018 01:21
-
-
Save ateneva/41cfadc917c477e3b471790443805bd5 to your computer and use it in GitHub Desktop.
Find the height and width of an Excel shape
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub ShowShapeDimensions() | |
Dim l As Long | |
Dim t As Long | |
Dim h As Long | |
Dim w As Long | |
Dim Sh As Shape | |
'---------------------------------------------- | |
For Each Sh In ActiveSheet.Shapes | |
If Sh.TopLeftCell.Address(0, 0) = "B2" Then | |
l = Sh.Left | |
t = Sh.Top | |
h = Sh.Height | |
w = Sh.width | |
End If | |
Next Sh | |
'Return Dimensions | |
ActiveSheet.Range("A1") = "Left: " & l | |
ActiveSheet.Range("A2") = "Top: " & t | |
ActiveSheet.Range("A3") = "Height: " & h | |
ActiveSheet.Range("A4") = "Width: " & w | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment