BENSON
07-13-2013, 06:58 AM
I have a spread sheet with a linked graph, also linked to this graph is macro that adds trend lines.I wish to protect the the whole spread sheet.If I click protect work sheet and tic ( Contents, Objects,Scenarios) The macro will not work.I have tried the code active sheet unprotect but to no avail.If I protect the work sheet but only tic (Contents and Scenarios) the macros will work but obviously the graphs remain unprotected.I have enclosed the code below showing me the error line when I try the macro with all 3 options ticked
Sub OptionButton8_Click()
' OptionButton8_Click Macro
' Macro recorded 2013/07/10 by Peter Beckett
'
'
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).Trendlines.Add(Type:=xlLogarithmic, Forward _
:=0, Backward:=0, DisplayEquation:=False, DisplayRSquared:=False).Select
ActiveChart.SeriesCollection(2).Select
ActiveChart.SeriesCollection(2).Trendlines.Add(Type:=xlLogarithmic, Forward _
:=0, Backward:=0, DisplayEquation:=False, DisplayRSquared:=False).Select
ActiveChart.SeriesCollection(2).Trendlines(1).Select
With Selection.Border
.ColorIndex = 46
.Weight = xlMedium
.LineStyle = xlContinuous
End With
ActiveWindow.Visible = False
Range("D18").Select
End Sub
Sub OptionButton8_Click()
' OptionButton8_Click Macro
' Macro recorded 2013/07/10 by Peter Beckett
'
'
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).Trendlines.Add(Type:=xlLogarithmic, Forward _
:=0, Backward:=0, DisplayEquation:=False, DisplayRSquared:=False).Select
ActiveChart.SeriesCollection(2).Select
ActiveChart.SeriesCollection(2).Trendlines.Add(Type:=xlLogarithmic, Forward _
:=0, Backward:=0, DisplayEquation:=False, DisplayRSquared:=False).Select
ActiveChart.SeriesCollection(2).Trendlines(1).Select
With Selection.Border
.ColorIndex = 46
.Weight = xlMedium
.LineStyle = xlContinuous
End With
ActiveWindow.Visible = False
Range("D18").Select
End Sub