ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Programming graphs to be placed in determined cell area (https://www.excelbanter.com/excel-programming/343993-programming-graphs-placed-determined-cell-area.html)

Moises

Programming graphs to be placed in determined cell area
 
I created a macro that genereates a set of graphs from a determined number of
data in an array, everytime that the program creates a graph , this graph is
placed in a specific (fixed) place in the sheet, what should I do to move the
graph every time it is created to a cell area that I know and I can control ?

Thanks for your help
Moises

Matt[_33_]

Programming graphs to be placed in determined cell area
 
Try this:

Dim rng As Range

Set rng = Range("A30").Resize(19, 5)
With ActiveSheet.ChartObjects(1)
.Top = rng.Top
.Left = rng.Left
.Width = rng.Width
.Height = rng.Height
End With


Not my own (is from Tom O)

Matt


K Dales[_2_]

Programming graphs to be placed in determined cell area
 
Ranges (i.e. cells) have a top, left, width and height property, and so do
ChartObjects. So set them equal; e.g. for fitting a chart to the range
B2:F20 you could do this:

Set MyGraph = Worksheets("SheetName").ChartObjects(1)
Set MyRange = Worksheets("SheetName").Range("B2:F20")
MyGraph.Top = MyRange.Top
MyGraph.Left = MyRange.Left
MyGraph.Width = MyRange.Width
MyGraph.Height = MyRange.Height

--
- K Dales


"Moises" wrote:

I created a macro that genereates a set of graphs from a determined number of
data in an array, everytime that the program creates a graph , this graph is
placed in a specific (fixed) place in the sheet, what should I do to move the
graph every time it is created to a cell area that I know and I can control ?

Thanks for your help
Moises



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

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