ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Activechart.parent.left (https://www.excelbanter.com/excel-programming/428495-activechart-parent-left.html)

David

Activechart.parent.left
 
Hi Group,

I am trying to place a chart in a specific location on the worksheet. This
code locates it to column N, but does not place it on Row 3, which I expected
to happen:

ActiveChart.Parent.Left = Range("N3").Left

I would also like to anchor it in the bottom right, basically locate and
size it. N3 to AB35.

Thanks for your help.

David

Tim Williams[_2_]

Activechart.parent.left
 
David,

Left is just left, not top left.

Dim rng as range
Set rng = Sheet1.Range("N3:AB35")

with ActiveChart.Parent
.Top = rng.Cells(1).Top
.Left = rng.Cells(1).Left
.width= rng.Width
.Height=rng.Height
end with


Tim

"David" wrote in message
...
Hi Group,

I am trying to place a chart in a specific location on the worksheet. This
code locates it to column N, but does not place it on Row 3, which I
expected
to happen:

ActiveChart.Parent.Left = Range("N3").Left

I would also like to anchor it in the bottom right, basically locate and
size it. N3 to AB35.

Thanks for your help.

David




David

Activechart.parent.left
 
Hi Tim,

Thank you. I tried to look up help, since this is not quite doing what I
expected, but help was not very helpful. It is difficult to see what the
measures are, but I think it is in pixels? Some of the results:
?rng.Cells(1).Top = 25.5
?rng.Cells(1).Left = 202.5
?rng.Width = 780
?rng.Height = 420.75

The left-top ended up in E3, so I guess I need to figure out the pixels to
get it to N3. Again, thnk you for your help.

David




"Tim Williams" wrote:

David,

Left is just left, not top left.

Dim rng as range
Set rng = Sheet1.Range("N3:AB35")

with ActiveChart.Parent
.Top = rng.Cells(1).Top
.Left = rng.Cells(1).Left
.width= rng.Width
.Height=rng.Height
end with


Tim

"David" wrote in message
...
Hi Group,

I am trying to place a chart in a specific location on the worksheet. This
code locates it to column N, but does not place it on Row 3, which I
expected
to happen:

ActiveChart.Parent.Left = Range("N3").Left

I would also like to anchor it in the bottom right, basically locate and
size it. N3 to AB35.

Thanks for your help.

David





Tim Williams[_2_]

Activechart.parent.left
 
David,

All I can say is it works for me. Is your chart located on Sheet1 ?
That was just an example, so you may need to modify to suit your situation

Here's a version which doesn't have a defined sheet reference - it just
looks at the sheet hosting the chart.

Sub Tester()
Dim rng As Range

With ActiveChart.Parent
Set rng = .Parent.Range("N3:AB35")
.Top = rng.Top
.Left = rng.Left
.Width = rng.Width
.Height = rng.Height
End With
End Sub

Tim


"David" wrote in message
...
Hi Tim,

Thank you. I tried to look up help, since this is not quite doing what I
expected, but help was not very helpful. It is difficult to see what the
measures are, but I think it is in pixels? Some of the results:
?rng.Cells(1).Top = 25.5
?rng.Cells(1).Left = 202.5
?rng.Width = 780
?rng.Height = 420.75

The left-top ended up in E3, so I guess I need to figure out the pixels to
get it to N3. Again, thnk you for your help.

David




"Tim Williams" wrote:

David,

Left is just left, not top left.

Dim rng as range
Set rng = Sheet1.Range("N3:AB35")

with ActiveChart.Parent
.Top = rng.Cells(1).Top
.Left = rng.Cells(1).Left
.width= rng.Width
.Height=rng.Height
end with


Tim

"David" wrote in message
...
Hi Group,

I am trying to place a chart in a specific location on the worksheet.
This
code locates it to column N, but does not place it on Row 3, which I
expected
to happen:

ActiveChart.Parent.Left = Range("N3").Left

I would also like to anchor it in the bottom right, basically locate
and
size it. N3 to AB35.

Thanks for your help.

David








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

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