Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel - Finding point location of a cell

Tags:

excel

vba

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...

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

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

expression.AddChart2(Style,XlChartType,Left,Top,Width,Height,NewLayout)
like image 886
user1009073 Avatar asked Dec 23 '22 23:12

user1009073


1 Answers

Try this:

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

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

like image 115
Andreas Avatar answered Dec 26 '22 14:12

Andreas