ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Positioning of Chart Objects on an Excel Sheet (https://www.excelbanter.com/excel-programming/381863-re-positioning-chart-objects-excel-sheet.html)

Peter T

Positioning of Chart Objects on an Excel Sheet
 
Hi Chris,

Dim chtObj as ChartObject
dim cht as Chart

Set chtObj = ActiveSheet.ChartObjects.Add(L, T, W, H)
Set cht = chtObj.Chart

and go on to add whatever to 'cht'

The coordinates might be those of a range to line up with cells, or whatever
position and size you require.

Regards,
Peter T


"Chris Gorham" wrote in message
...
Hi,

I've written a graph plotting program that outputs the charts either as

new
sheets in the workbook or alternatively as objects placed in order on a

new
worksheet.

I'm having difficulty persuading the code to place the charts in a neat
order on the sheet...

Is it possible to link the chart object to a cell range rather than

specify
coordinates...??

Thanks...Chris





Peter T

Positioning of Chart Objects on an Excel Sheet
 
eg -

Sub test()
Dim j As Long, k As Long
Dim chtObj As ChartObject
Dim cht As Chart
Dim sr As Series

For k = 2 To 2 + (5 * 3) Step 5

For j = 2 To 2 + (10 * 4) Step 10
Set rng = Range(Cells(j, k), Cells(j + 7, k + 3))

With rng

Set chtObj = ActiveSheet.ChartObjects.Add(.Left, .Top, .Width, .Height)
Set cht = chtObj.Chart
Set sr = cht.SeriesCollection.NewSeries
sr.Values = "{1,2,3}"

End With

Next
Next

End Sub

Peter T


"Peter T" <peter_t@discussions wrote in message
...
Hi Chris,

Dim chtObj as ChartObject
dim cht as Chart

Set chtObj = ActiveSheet.ChartObjects.Add(L, T, W, H)
Set cht = chtObj.Chart

and go on to add whatever to 'cht'

The coordinates might be those of a range to line up with cells, or

whatever
position and size you require.

Regards,
Peter T


"Chris Gorham" wrote in message
...
Hi,

I've written a graph plotting program that outputs the charts either as

new
sheets in the workbook or alternatively as objects placed in order on a

new
worksheet.

I'm having difficulty persuading the code to place the charts in a neat
order on the sheet...

Is it possible to link the chart object to a cell range rather than

specify
coordinates...??

Thanks...Chris








All times are GMT +1. The time now is 08:38 AM.

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