Excel Chart with equal length axis

G

Guest

Is it possible to create a chart that is square?
i.e. the length of the x axis is equal to the length of the y axis
and be centered in landscape?
 
A

Andy Pope

Hi,

I this you are going to need VBA code to do this.
This example uses the smallest length to square the chart to.

'--------------------------------------
Sub Squareplot()
Application.ScreenUpdating = False
With ActiveChart
If .PlotArea.InsideHeight > .PlotArea.InsideWidth Then
Do While .PlotArea.InsideWidth < .PlotArea.InsideHeight
.PlotArea.Height = .PlotArea.Height - 1
Loop
Else
Do While .PlotArea.InsideHeight < .PlotArea.InsideWidth
.PlotArea.Width = .PlotArea.Width - 1
Loop
End If
.PlotArea.Left = (.ChartArea.Width - .PlotArea.Width) / 2
.PlotArea.Top = (.ChartArea.Height - .PlotArea.Height) / 2
End With
Application.ScreenUpdating = True
End Sub
'------------------------------------

Cheers
Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top