Macro error in editing chart series on a protected sheet

acidburn170

New Member
Joined
Feb 20, 2018
Messages
1
Hello,

I am using Excel 2007 and have a protected sheet containing a macro within that sheet. I want the macro to change the data and it does so when the sheet is unprotected. Once I protect it, I am getting this error - Method 'Name' of object 'Series' failed.

How could I fix this macro so that it runs when worksheet is protected? :confused:


Code:
Sub COIAspen()'
' Aspen Macro
'


'   ActiveSheet.Unprotect "TEST"
    ActiveSheet.ChartObjects("Chart 5").Activate
    ActiveSheet.ChartObjects("Chart 5").Activate
[B]    ActiveChart.SeriesCollection(1).Name = "='YEAR-TO-DATE FOR 2018'!$B$20"[/B]
    ActiveChart.SeriesCollection(1).Values = "='YEAR-TO-DATE FOR 2018'!$C$20:$N$20"
    ActiveSheet.Protect "TEST"
End Sub


Thank you!
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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