Error with plots

Padatwo

New Member
Joined
Apr 12, 2016
Messages
2
Hello I'm new in VBA and currently trying to make a bubble plot in EXCEL 2016 with VBA but every time I run the macros it gives me back System "Error &H80070057 (-2147024809)". The code I'm using is:

Sub graphic2()
ActiveSheet.Shapes.AddChart2(269, xlBubble).Select
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(1).Name = "=""dots"""
ActiveChart.FullSeriesCollection(1).XValues = "=Aux2!$B2:$B10001"
ActiveChart.FullSeriesCollection(1).Values = "=Aux2!$C2:$C10001"
ActiveChart.FullSeriesCollection(1).BubbleSizes = "=Aux2!$D2:$D10001"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(2).Name = "=""clusters"""
ActiveChart.FullSeriesCollection(2).XValues = "=Aux2!$G2:$G501"
ActiveChart.FullSeriesCollection(2).Values = "=Aux2!$H2:$H501"
ActiveChart.FullSeriesCollection(2).BubbleSizes = "=Aux2!$I2:$I501"
ActiveChart.SetElement (msoElementDataLabelCenter)
ActiveChart.SetElement (msoElementDataLabelNone)
ActiveChart.SetElement (msoElementChartTitleAboveChart)
ActiveChart.SetElement (msoElementLegendRight)
ActiveChart.ChartTitle.Text = "Clusters calculados"
Selection.Format.TextFrame2.TextRange.Characters.Text = "Clusters calculied"

With Selection.Format.TextFrame2.TextRange.Characters(1, 20).ParagraphFormat
.TextDirection = msoTextDirectionLeftToRight
.Alignment = msoAlignCenter
End With

With Selection.Format.TextFrame2.TextRange.Characters(1, 9).Font
.BaselineOffset = 0
.Bold = msoFalse
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(89, 89, 89)
.Fill.Transparency = 0
.Fill.Solid
.Size = 14
.Italic = msoFalse
.Kerning = 12
.Name = "+mn-lt"
.UnderlineStyle = msoNoUnderline
.Spacing = 0
.Strike = msoNoStrike
End With

With Selection.Format.TextFrame2.TextRange.Characters(10, 10).Font
.BaselineOffset = 0
.Bold = msoFalse
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(89, 89, 89)
.Fill.Transparency = 0
.Fill.Solid
.Size = 14
.Italic = msoFalse
.Kerning = 12
.Name = "+mn-lt"
.UnderlineStyle = msoNoUnderline
.Spacing = 0
.Strike = msoNoStrike
End With

With Selection.Format.TextFrame2.TextRange.Characters(20, 1).Font
.BaselineOffset = 0
.Bold = msoFalse
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(89, 89, 89)
.Fill.Transparency = 0
.Fill.Solid
.Size = 14
.Italic = msoFalse
.Kerning = 12
.Name = "+mn-lt"
.UnderlineStyle = msoNoUnderline
.Spacing = 0
.Strike = msoNoStrike
End With

ActiveChart.ChartArea.Select

End Sub

Can anyone explain me what the problem might be?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
The characters are out of bound: you have 17 characters in "Clusters calculied" yet you're asking to format the first 20.

With Selection.Format.TextFrame2.TextRange.Characters(1, 20).ParagraphFormat

Same with With Selection.Format.TextFrame2.TextRange.Characters(10, 10).Font -- should be
With Selection.Format.TextFrame2.TextRange.Characters(10, 7).Font

and again with With Selection.Format.TextFrame2.TextRange.Characters(20, 1).Font -- there aren't 20 characters in the selection
 
Upvote 0

Forum statistics

Threads
1,226,694
Messages
6,192,473
Members
453,726
Latest member
JoeH57

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