Home » excel » vba – How to resize chart sheets in Excel

vba – How to resize chart sheets in Excel

Posted by: admin April 23, 2020 Leave a comment

Questions:

To be clear, I’m not asking how to resize charts ON a worksheet, but how to resize Charts that ARE worksheets.

I want to resize the chart to be 3.79cm high and 5.91 wide.

Though I have done this in the past already, I’m currently at a loss of how I did it. I’ve been trying and playing around with the code below:

Sub qqq()
Dim x

With Chart6
    .ChartArea.Height = 379.03
    .ChartArea.Width = 591.03
End With

End Sub

When I try to run it I get “Run Time Error 5”

What am I missing/not seeing?

How to&Answers:

The issue is that the input for Height and Width are in points and not in mm!

Using this converter (1 Centimeter = 28.346… Points) or the built-in function CentimetersToPoints :

Sub qqq()
Dim x

With Chart6
    .ChartArea.Height = 107.3
    .ChartArea.Width = 167.5
    .ChartArea.Height = CentimetersToPoints(3.79)
    .ChartArea.Width = CentimetersToPoints(5.91)
End With

End Sub