vba 如何在Excel中获取范围的大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2237873/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 10:16:12  来源:igfitidea点击:

How to get the size of a range in Excel

excelvbaexcel-vbasizerange

提问by Cameron

Using VBA, is it possible to get the size of a given range in terms of pixels or units? (I don't care which unit as I am only using it to relate to other measurements with the same unit).

使用 VBA,是否可以根据像素或单位获得给定范围的大小?(我不在乎哪个单位,因为我只使用它来与具有相同单位的其他测量值相关联)。

Thanks.

谢谢。

回答by Tomalak

The overall dimensions of a range are in its Widthand Heightproperties.

一个范围的整体尺寸在它的WidthHeight属性中。

Dim r As Range
Set r = ActiveSheet.Range("A4:H12")

Debug.Print r.Width
Debug.Print r.Height

回答by Chris McCall

The Rangeobject has both width and height properties, which are measured in points.

范围对象具有宽度和高度属性,其在点测量。