vba Excel - 查找单元格的点位置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40655009/
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-12 11:33:22  来源:igfitidea点击:

Excel - Finding point location of a cell

excelvba

提问by user1009073

In Excel 2013, I am programmatically adding a chart. To do so, I need to specify WHERE the chart is located. Specifically top, left, height and width. All these coordinates are points, not cell addresses. For example, the default height of a cell if 15 points. I know the cell address where I want the Graph to be located. How do I convert a cell address to a point? There has to be a better way than just iterating through every previous row/column and adding their height/width...

在 Excel 2013 中,我以编程方式添加图表。为此,我需要指定图表所在的位置。特别是顶部,左侧,高度和宽度。所有这些坐标都是点,而不是单元格地址。例如,单元格的默认高度为 15 磅。我知道我希望图形所在的单元格地址。如何将单元格地址转换为点?必须有更好的方法,而不仅仅是遍历每一行/列并添加它们的高度/宽度......

For example, Cell 'F7' might be 120 points left, and have a top point location of 90.

例如,单元格“F7”可能在左侧 120 个点,并且顶点位置为 90。

If it helps any, the syntax to add the chart is...

如果有帮助,添加图表的语法是......

expression.AddChart2(Style,XlChartType,Left,Top,Width,Height,NewLayout)

回答by Andreas

Try this:

尝试这个:

    X = Range("N4").Left
    Y = Range("N4").Top

I don't have anything to test it on so not sure it works.

我没有任何东西可以测试它,所以不确定它是否有效。