Chart placement

  • Thread starter Thread starter David
  • Start date Start date
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
 
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
 
Thank you Debra. In looking through all the help files, I
could not figure this out. Greatly appreciated.
 

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