Chart placement

D

David

Hi Group,

Thanks in advance. I have a chart created in VBA. Now I
want it to appear in a specific place on the worksheet. I
see code to move it around in pixels, I think that is
what it is anyway, but I don't see a way to place it on a
particular cell ie. upperleft corner of chart over "M2."
I see methods to find out what cell it is over, both
upper left corner and bottom right corner, but not ways
to "put" over certain cells. I was moving it in pixels,
but it is not consistantly placed in the same place on
the sheet to reliabily move it, to the same spot.

Thanks
 
D

Debra Dalgleish

The following code postions the top left of the chart at the top left of
cell M2:

Sub PositionChart()
Dim ws As Worksheet
Dim chObj As ChartObject

Set ws = Sheets("Sheet1")
Set chObj = ws.ChartObjects(1)

With chObj
.Top = ws.Range("M2").Top
.Left = ws.Range("M2").Left
End With

End Sub
 
D

David

Thank you Debra. In looking through all the help files, I
could not figure this out. Greatly appreciated.
 
Top