Resizing Graphs

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have problems with Excel when there are tons of graphs i hve to create with all the graphs being on one page. Having to resize all of them when they are all ALREADY different sizes is a pain. I know how to hold down the control key and select them and resize them all at once, but some or still larger than others unless i resize them individually. Is there a way to make them all the same height adn width some how? or is this just a dream? Must i resize all of them individually?
 
I personally use an add-in (.xla) which includes the following code (you can
pick up the size of a chart with ctrl-shift-d and apply it to another chart
with ctrl-shift-f, applying ctrl-shift-f to all the charts shouldn't take
too long). Any comments on this code would be appreciated (as would an
answer to the question I asked yesterday!):

in ThisWorkbook:

Private Sub Workbook_Open()
Application.OnKey "^+d", "PickUpUserSize"
Application.OnKey "^+f", "ApplyUserSize"
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.OnKey "^+d"
Application.OnKey "^+f"
End Sub

in Module1:

Option Explicit
Dim userwidth, userheight As Double
Sub PickUpUserSize()
On Error Resume Next
Selection.Activate
On Error GoTo Errorhandler
ActiveChart.ChartArea.Select
ActiveWindow.Visible = False
userwidth = Selection.Width
userheight = Selection.Height
Selection.Activate
Exit Sub
Errorhandler:
Beep
End Sub

Sub ApplyUserSize()
On Error Resume Next
Selection.Activate
On Error GoTo Errorhandler
ActiveChart.ChartArea.Select
Selection.AutoScaleFont = False
ActiveWindow.Visible = False
Selection.Width = userwidth
Selection.Height = userheight
Selection.Activate
Exit Sub
Errorhandler:
Beep
End Sub


Jacob said:
I have problems with Excel when there are tons of graphs i hve to create
with all the graphs being on one page. Having to resize all of them when
they are all ALREADY different sizes is a pain. I know how to hold down the
control key and select them and resize them all at once, but some or still
larger than others unless i resize them individually. Is there a way to make
them all the same height adn width some how? or is this just a dream? Must
i resize all of them individually?
 
Stephen -

This one will eliminate selecting any but the first chart, which has the
desired size:

Sub SizeChartsTheSame
Dim oCht As ChartObject
Dim ht As Double, wd As Double
If ActiveChart Is Nothing Then
MsgBox "Select the chart you want to use as a pattern," & _
vbcrlf & "then try again.", vbExclamation, "Select a Chart"
Else
With ActiveChart.Parent
ht = .Height
wd = .Width
End With
For Each oCht in ActiveSheet.ChartObjects
With oCht
.Height = ht
.Width = wd
End With
Next
End If
End Sub

- Jon
 
Back
Top