Ordering graphs

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

Guest

'Unable I have 4 graphs in a row under some data, which are generated into
excel format from a database.
I need to place these 4 graphs onto another workbook, in a particular
configuration, eg, instead of being in a row, I now want them 2x2.
I am having no luck in recording a macro.

I would be grateful for any suggestions how to achieve this.
I use Excel 2002.

Many thanks,

Geoff.
 
Hi Geoff -

This assumes the charts are made in a particular order, etc., etc. It also doesn't
stop at 4 charts, it will do all that you have on the initial sheet. Change the
workbook and sheet references for your particular situation.

Sub MoveLinearChartsToArray()
Dim wsSource As Worksheet
Dim wsTarget As Worksheet
Dim i As Integer

Set wsSource = Workbooks("Book4").Worksheets(1)
Set wsTarget = Workbooks("Book5").Worksheets(1)

For i = 1 To wsSource.ChartObjects.Count
wsSource.ChartObjects(i).Copy
wsTarget.Paste
With wsTarget.ChartObjects(i)
.Left = .Width * ((i - 1) Mod 2)
.Top = Int((i - 1) / 2) * .Height
End With
Next

End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______
 
Thanks Jon, Exactly what I needed ! Will really help speed things along,
since this process needs to be done many times over.

Thanks again.

Geoff.
 

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

Back
Top