Problems with running a macro

jbeatt23

New Member
Joined
Apr 21, 2014
Messages
3
Hi,

I used the macro record button and then made a graph from start to finish (on sheet 2, where all my data is on sheet 1). Then I created a button to run the macro, linked that button to the maco I made. However when I click the button to run the maco I get the error seen below


Then the graph shows up, on sheet 1 even though that is not where I made it.

How do I fix this?

I do not know what the error means or what to do. This is my first excel macro.

Thanks for the help
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Oh it does not look like my picture showed up, the error I got was a Microsoft Visual Basic, runt time error. The item with the specified name wasn't found.
 
Upvote 0
Here is the code that was created.


Sub Macro6()
'
' Macro6 Macro
'
'
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).Name = "=Sheet1!$C$1"
ActiveChart.SeriesCollection(1).Values = "=Sheet1!$C$2:$C$203"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(2).Name = "=Sheet1!$D$1"
ActiveChart.SeriesCollection(2).Values = "=Sheet1!$D$2:$D$203"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(3).Name = "=Sheet1!$E$1"
ActiveChart.SeriesCollection(3).Values = "=Sheet1!$E$2:$E$203"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(4).Name = "=Sheet1!$F$1"
ActiveChart.SeriesCollection(4).Values = "=Sheet1!$F$2:$F$203"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(5).Name = "=Sheet1!$G$1"
ActiveChart.SeriesCollection(5).Values = "=Sheet1!$G$2:$G$203"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(6).Name = "=Sheet1!$H$1"
ActiveChart.SeriesCollection(6).Values = "=Sheet1!$H$2:$H$203"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(7).Name = "=Sheet1!$I$1"
ActiveChart.SeriesCollection(7).Values = "=Sheet1!$I$2:$I$203"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(8).Name = "=Sheet1!$J$1"
ActiveChart.SeriesCollection(8).Values = "=Sheet1!$J$2:$J$203"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(9).Name = "=Sheet1!$K$1"
ActiveChart.SeriesCollection(9).Values = "=Sheet1!$K$2:$K$203"
ActiveChart.SeriesCollection(9).XValues = "=Sheet1!$B$2:$B$203"
ActiveSheet.Shapes("Chart 4").ScaleWidth 1.4729166667, msoFalse, _
msoScaleFromTopLeft
ActiveSheet.Shapes("Chart 4").ScaleHeight 1.46875, msoFalse, _
msoScaleFromTopLeft
ActiveSheet.Shapes("Chart 4").ScaleWidth 1.2135783522, msoFalse, _
msoScaleFromBottomRight
ActiveSheet.Shapes("Chart 4").ScaleHeight 1.2505907684, msoFalse, _
msoScaleFromBottomRight
ActiveWindow.SmallScroll Down:=12
ActiveSheet.Shapes("Chart 4").ScaleWidth 1.1317016478, msoFalse, _
msoScaleFromBottomRight
ActiveSheet.Shapes("Chart 4").ScaleHeight 1.3043478865, msoFalse, _
msoScaleFromTopLeft
ActiveWindow.SmallScroll Down:=0
ActiveSheet.Shapes("Chart 4").ScaleWidth 1.0782699415, msoFalse, _
msoScaleFromBottomRight
ActiveSheet.Shapes("Chart 4").ScaleHeight 1.3115944025, msoFalse, _
msoScaleFromTopLeft
ActiveWindow.SmallScroll Down:=6
ActiveChart.SetElement (msoElementChartTitleAboveChart)
ActiveWindow.SmallScroll Down:=-36
Selection.Caption = "Bottom 25% of Cars, Response Delay"
ActiveChart.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
Selection.Caption = "Drive Rating"
ActiveChart.SetElement (msoElementPrimaryValueAxisTitleRotated)
Selection.Caption = "Percent of Events"
ActiveChart.SetElement (msoElementPrimaryValueGridLinesMinorMajor)
ActiveWindow.ScrollRow = 2
ActiveWindow.ScrollRow = 5
ActiveWindow.ScrollRow = 6
ActiveWindow.ScrollRow = 7
ActiveWindow.ScrollRow = 9
ActiveWindow.ScrollRow = 10
ActiveWindow.ScrollRow = 11
ActiveWindow.ScrollRow = 13
ActiveWindow.ScrollRow = 14
ActiveWindow.ScrollRow = 15
ActiveWindow.ScrollRow = 16
ActiveWindow.ScrollRow = 17
ActiveWindow.ScrollRow = 18
ActiveWindow.ScrollRow = 19
ActiveWindow.ScrollRow = 21
ActiveWindow.ScrollRow = 22
ActiveWindow.ScrollRow = 23
ActiveWindow.ScrollRow = 24
ActiveWindow.ScrollRow = 25
ActiveWindow.ScrollRow = 26
ActiveWindow.ScrollRow = 27
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,088
Messages
6,123,057
Members
449,091
Latest member
ikke

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