I cant write a code that protects my chart from formatting. No error appears but after running the code I can still change formatting of the chart. Maybe you know how I can make it works.
ActiveSheet.ChartObjects("Chart 2").Activate With ActiveChart Application.ActiveChart.ProtectFormatting = True End With
Except for the basics, your code looks fine to me. You can do this with one line however:
ActiveSheet.ChartObjects("Chart 2").Chart.ProtectFormatting = True
This works for me anyway. Obviously, this doesn’t stop the chart being changed through code.