Banaticus
09-07-2006, 03:55 AM
One of my teachers is us having graphically add vectors. I choose not to use paper/pencil/protractor, but instead to draw them in Excel. The only problem is that Excel doesn't automatically size the charts appropriately. I can set the min/max for the x/y values to be the same range, but how do I get the chart itself to be square? I tried holding down shift while dragging the bottom right corner, but that only resizes the chart proportionately, it doesn't force the chart to be square.
How can I make the charts be completely square, so that someone using a protractor to check out the vectors in the charts will find them at the correct angle?
Check out what I have already:
http://banaticus.googlepages.com/VectorAddition.xls
shades
09-08-2006, 10:52 AM
Howdy. Jon Peltier has written code to make all charts the same size. By adjusting this, you could use constants so that after changing data, you could run this code and resize the chart. Due to work pressures, I don't have time to do it for you, but if you know VBA at all, you should be able to adjust.
Sub ResizeAllChartObjects()
'Apply Activechart sizes for both chart and plotarea to all
'other charts on this page.
'Jon Peltier provided this code
Dim objDefaultChart As Chart
Dim objChart As ChartObject
Dim intIndex As Integer
On Error Resume Next
If ActiveSheet.ChartObjects.Count > 1 Then
' only bother if there are more than 1 chartobject
Set objDefaultChart = ActiveChart
If Not (objDefaultChart Is Nothing) Then
For intIndex = 1 To ActiveSheet.ChartObjects.Count
Set objChart = ActiveSheet.ChartObjects(intIndex)
If objChart.Name = objDefaultChart.Name Then
' This chart is already correct
Else
With objChart
.Width = objDefaultChart.Parent.Width
.Height = objDefaultChart.Parent.Height
With .Chart.PlotArea
.Width = objDefaultChart.PlotArea.Width
.Height = objDefaultChart.PlotArea.Height
End With
End With
End If
Next
Else
' No Active chart
MsgBox "Please select chart on which to base sizes", vbExclamation
End If
End If
End Sub