ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   chart objects top (https://www.excelbanter.com/excel-programming/443632-chart-objects-top.html)

Neil[_33_]

chart objects top
 
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


Neil[_33_]

chart objects top
 
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

"Neil" wrote in message
nd.com...
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




All times are GMT +1. The time now is 06:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com