Positioning a Chart

kcatherine

New Member
Joined
Dec 3, 2014
Messages
3
I cannot get this chart to position on the page where I want it to. It will not move to the left. I want the Chart to go across cells E4:K4 and the height to be from E4:E18.
Code:
Sub Charts()
Worksheets("Reports").Activate
ActiveSheet.Range("B6:C31").SpecialCells(xlCellTypeConstants).Select
Set myChart = ActiveSheet.Shapes.AddChart.Chart
myChart.ChartType = xlColumnStacked
myChart.HasLegend = False
myChart.HasTitle = True
myChart.ChartTitle.Text = "Employees By Pay Rate"
myChart.Location xlLocationAsObject, "Charts"
Worksheets("Charts").Activate
With ActiveChart.Parent
        .Top = Rows(4).Top
        .Width = Range("E4:K4").Width
        .Height = Range("E4:E18").Height
        .Left = Range("E4").Left
End With
End Sub
 
Last edited by a moderator:

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Hi and welcome to the forum.

Try this:

Code:
Sub Charts()
Worksheets("Reports").Activate
ActiveSheet.Range("B6:C31").SpecialCells(xlCellTypeConstants).Select
Set myChart = Worksheets("Charts").Shapes.AddChart.Chart
myChart.ChartType = xlColumnStacked
myChart.HasLegend = False
myChart.HasTitle = True
myChart.ChartTitle.Text = "Employees By Pay Rate"

With myChart.Parent
        .Top = Rows(4).Top
        .Width = Range("E4:K4").Width
        .Height = Range("E4:E18").Height
        .Left = Range("E4").Left
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,222,827
Messages
6,168,480
Members
452,192
Latest member
FengXue

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