Getting Run Time Error ( Out of Range ) when trying to change the Title of Pareto Chart

Tadeu

New Member
Joined
Feb 6, 2018
Messages
1
Hi all,

I'm a beginner on VBA, and sorry if my code is not clean. i'm trying to create a Pareto chart on the same worksheet where i already have another column chart. I used the Macro recorder to get the code.
The First Chart is working fine. When i try to add the second chart ( Pareto ), i'm getting a error message: Run Time error ' -21470224809(80070057) The specified value is out of range."

I have added this to the code ( ActiveSheet.Shapes.AddChart2(5, xlPareto).Select ), because when i execute the macro recorder this not appear on the code generate by the process, and when i try to proceed the Chart was reffering to the first chart ( Column Chart ) and not to the new one that i'm trying to create. I don't know why. Maybe this can be related to this error somehow.

This is the Function below :


Sub ParetoGraph(xPin, xPfi, xcL2, xcL1, xL2, xL1)

Range(xPin & ":" & xPfi).Select
ActiveSheet.Shapes.AddChart2(5, xlPareto).Select
ActiveChart.Parent.Name = "4Q Pareto"
ActiveSheet.ChartObjects("4Q Pareto").Activate
ActiveWindow.SmallScroll Down:=-9
ActiveSheet.Shapes("4Q Pareto").IncrementLeft 168
ActiveSheet.Shapes("4Q Pareto").IncrementTop -134.25
ActiveWindow.SmallScroll Down:=-6
ActiveSheet.Shapes("4Q Pareto").IncrementLeft -12.75
ActiveSheet.Shapes("4Q Pareto").IncrementTop -122.25
ActiveSheet.Shapes("4Q Pareto").Chart.HasTitle = True
ActiveSheet.Shapes("4Q Pareto").TextFrame2.TextRange.Characters.Text = "LATE - Root Cause"
ActiveSheet.Shapes("4Q Pareto").TextFrame2.TextRange.Characters(1, 17).ParagraphFormat.Alignment = msoAlignCenter
With ActiveSheet.Shapes("4Q Pareto").TextFrame2.TextRange.Characters(1, 17).Font
.BaselineOffset = 0
.Bold = msoFalse
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(89, 89, 89)
.Fill.Transparency = 0
.Fill.Solid
.Size = 14
.Italic = msoFalse
.Kerning = 12
.Name = "Calibri"
.UnderlineStyle = msoNoUnderline
.Spacing = 0
.Strike = msoNoStrike
End With
Range("N21").Select
ActiveWindow.SmallScroll Down:=15
Range("C25").Select
ActiveWindow.SmallScroll Down:=-12
ActiveSheet.Shapes.Range(Array("4Q Pareto")).Select
ActiveWindow.SmallScroll Down:=6
ActiveChart.SetSourceData Source:=Range("'4Q Report'!$C$26:$G$&xcL2")
Range("N21").Select
ActiveWindow.SmallScroll Down:=-12


End Sub


Thanks in advanced...

Tadeu
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

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