Activechart.parent.left

  • Thread starter Thread starter David
  • Start date Start date
D

David

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,

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
 
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
 
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
 
Back
Top