ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Chart placement (https://www.excelbanter.com/excel-programming/295432-chart-placement.html)

David

Chart placement
 
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

Debra Dalgleish

Chart placement
 
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


David wrote:
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



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html


David

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

-----Original Message-----
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


David wrote:
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



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

.



All times are GMT +1. The time now is 01:19 PM.

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