ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Ordering graphs (https://www.excelbanter.com/excel-programming/319198-ordering-graphs.html)

Geoff

Ordering graphs
 
'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.

Jon Peltier[_9_]

Ordering graphs
 
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/
_______


Geoff wrote:

'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.



Geoff

Ordering graphs
 
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.

"Jon Peltier" wrote:

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/
_______


Geoff wrote:

'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.





All times are GMT +1. The time now is 04:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com