Help Please!!! Error with my graph macro

Excelme1

New Member
Joined
Jun 23, 2011
Messages
12
I have searched the forum for similar questions but can’t seem to find anything that would help me. I’m new to VBA so apologies in advance for any obvious mistakes. Here is the Macro I recorded and I have over 25 graphs I need to make the same change as I made to this one. However, when I activate the next sheet the macro comes up with an error stating "Run time err. The item with the specified name wasn't found". Please help any advice will be appreciated. Thanks!!!

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p>Sub Macro1()
'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+Shift+K
'
Sheets("Aged Corr Chart").Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(1).Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(4).Name = "='Chart data'!$M$2"
ActiveChart.SeriesCollection(4).Values = "='Chart data'!$M$3:$M$80"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(5).Name = "='Chart data'!$N$2"
ActiveChart.SeriesCollection(5).Values = "='Chart data'!$N$3:$N$80"
End Sub
</o:p>
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Yes. Chart1 is in sheet (Aged Corr Chart). I even tried changing the name "Chart 1" to "Chart1" since that is the way it's listed undet the list of excel objects,but so far no luck.
 
Upvote 0
No... using ChartObjects it should be the name as it appears in below the ribbon on the left hand side of the workbook.
If you recorded the macro it should work on the sheet you recorded it on... does it?
What are the names of the other sheets?
 
Last edited:
Upvote 0
remove
Sheets("Aged Corr Chart").Select


close



select the sheet first

Then run your macro so it runs on the currently selected sheet ( assuming said sheet as a Chart 1 on it)
 
Last edited:
Upvote 0
Nope, it seems the problem is with this line. ActiveSheet.ChartObjects("Chart 1").Activate that line comes up twice and both times causes an error.
 
Upvote 0

Forum statistics

Threads
1,224,559
Messages
6,179,515
Members
452,921
Latest member
BBQKING

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