I have a macro that automatically creates a large number of graphs. Unfortunately, the graphs end up exactly on top of one another. Does anyone know a macro command that would allow me to tile an arbitrary number of graphs?
Thanks,
Eric
I have a macro that automatically creates a large number of graphs. Unfortunately, the graphs end up exactly on top of one another. Does anyone know a macro command that would allow me to tile an arbitrary number of graphs?
Thanks,
Eric
Last edited by matrixee; 01-27-2005 at 06:39 PM.
I am making all the charts of same width and height
You can go throught the code comments.
You have option to change the width,height of chart, number of charts per row.
I want you to backup the original file and try this macro
Sub Macro1()
Dim width_c, height_c, chart_in_row As Variant
Dim i As Integer
Dim count As Variant
Dim k, k1, k2 As Variant
k = 1
i = 0
k1 = 1
k2 = 0
width_c = 250 'defining the width of the chart
height_c = 250 'defining the height of the chart
chart_in_row = 3 'defining number of charts in row
count = ActiveSheet.ChartObjects.count 'number of charts
MsgBox count
While i = 0
If k2 = count Then
i = 1
End
End If
For c = 1 To chart_in_row
If k2 = count Then ' checking to see if all charts are covered
i = 1
End
End If
On Error Resume Next
ActiveSheet.ChartObjects("Chart " & k).Activate
If Err.Description <> "" Then
c = c - 1
Err.Clear
Else
ActiveChart.ChartArea.Select
ActiveSheet.Shapes("Chart " & k).Left = (width_c * c) - width_c ' assigning left position value
ActiveSheet.Shapes("Chart " & k).Height = height_c ' assigning height value
ActiveSheet.Shapes("Chart " & k).Width = width_c ' assigning width value
ActiveSheet.Shapes("Chart " & k).Top = (height_c * k1) - height_c 'assigning top position value
k2 = k2 + 1 ' incrementing number of charts found value
End If
k = k + 1 ' incrementing chart array value
Next
k1 = k1 + 1 'incrementing rows
Wend
End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks