Placing charts within a sheet

S Haspel

New Member
Joined
Jan 23, 2006
Messages
46
I'm running a macro which is creating a series of charts and am trying to get the code to place them.

Is there a line of code which lets you define the top left corner point or anything? I'm using .Parent.Width and .Parent.Height to define the size. Is there a Parent.Location or .Parent.Address which lets me specify the co-ordinates?


Regards
Simon
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Hi,

Is there a line of code which lets you define the top left corner point or anything? I'm using .Parent.Width and .Parent.Height to define the size. Is there a Parent.Location or .Parent.Address which lets me specify the co-ordinates?

Any object like Cell or Shape has its Top and Left coordinates. You may use something like this:

Code:
With ActiveSheet.ChartObjects("Chart 1")
 .Top = 100
 .Left = 100
End With
 
Upvote 0
This code lets you position a chart so it covers cells B12:G24 inclusive --
Code:
Sub Macro2()
    Dim sglHeight As Single
    Dim sglWidth As Single
    Dim sglTop As Single
    Dim sglLeft As Single

    sglTop = Range("B12").Top
    sglLeft = Range("B12").Left
    sglHeight = Range("B25").Top - Range("B12").Top
    sglWidth = Range("H12").Left - Range("B12").Left
    
    ActiveSheet.ChartObjects("Chart 1").Activate
    ActiveChart.ChartArea.Select
    With ActiveSheet.Shapes("Chart 1")
        .Top = sglTop
        .Left = sglLeft
        .Height = sglHeight
        .Width = sglWidth
    End With
End Sub
Denis
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,243
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top