• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How do I find pixel size of a range

Ulrik Willemoes

New Member
Is there an easy way of obtaining information on the pixel size of a range (say width and height of the area A1:B2 or a defined print area)?

Can it be done by means of a formula or does one need to resort to VBA?
 
Ulrik

Draw a Rectangle on your worksheet, snapping it to the area you want to query with the Alt Drag method

Name it "Rectangle 1"

Copy the following code into a Macro Module

Then execute the macro ShpSize

[pre]
Code:
Sub ShpSize()

Obj = "Rectangle 1"
ActiveSheet.Shapes.Range(Obj).Select

Top = "Top = " + Str(Selection.ShapeRange.Top)
MsgBox Top

ShpHeight = Selection.ShapeRange.Top + Selection.ShapeRange.Height
Bottom = "Bottom = " + Str(ShpHeight)
MsgBox Bottom

Top = "Left = " + Str(Selection.ShapeRange.Left)
MsgBox Top

ShpWidth = Selection.ShapeRange.Left + Selection.ShapeRange.Width
TRight = "Right = " + Str(ShpWidth)
MsgBox TRight

End Sub
[/pre]
 
Back
Top