chart objects top

  • Thread starter Thread starter Neil
  • Start date Start date
N

Neil

Hi,

I have the following code to move a chart to the top of the visible window
which works fine in 2003, however with the same workbook when opened in 2010
i get a runtime error on the line:

ChartObjects(1).Top = Rows(ActiveWindow.ScrollRow).Top

Error is
-2147024809 (80070057)
The specified value is out of range.

Any help in solving this would be greatly appreciated, thanks in advance

Neil

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim ch
'Exit Sub
If Not Intersect(Target, Range("a2:A74")) Is Nothing Then
ChartObjects(1).Top = Rows(ActiveWindow.ScrollRow).Top
For Each ch In ActiveSheet.ChartObjects
If ch.Name = "Chart 15" Then
ch.Visible = True
Updatechart
End If
Next
Else
For Each ch In ActiveSheet.ChartObjects
If ch.Name = "Chart 15" Then ch.Visible = False
Next
End If
End Sub
 
I had the worksheet protected, works as soon as I took off the protection.
Still don't understand why it worked in 2003 with the protection on.

Neil
 
Back
Top