View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Andy Pope Andy Pope is offline
external usenet poster
 
Posts: 2,489
Default Pasting line to a chart point

Hi,

No need to select things. This works for me and does nothing if last
point in data series is empty or #N/A.

Sub drawline()

Dim vntData As Variant

ActiveSheet.Shapes("Line 969").Copy

With ActiveSheet.ChartObjects("Chart 967").Chart.SeriesCollection(4)
vntData = .Values
If Not IsError(vntData(.Points.Count)) Then
.Points(.Points.Count).Paste
End If
End With

End Sub

Cheers
Andy

Paul wrote:
The following code fails in the next to last line with error statement,
"Select method of point class failed"

If i use an integer rather than the variable, it works; however, I need to
use the variable to paste the line to he most recent point.

What am I doing wrong???

Sub drawline()
ActiveSheet.ChartObjects("Chart 967").Activate
ActiveChart.SeriesCollection(4).Select
xxx = ActiveChart.SeriesCollection(4).Points.Count
Range("X1").Select
ActiveSheet.Shapes("Line 969").Select
Selection.Copy
ActiveSheet.ChartObjects("Chart 967").Activate
ActiveChart.SeriesCollection(4).Select
ActiveChart.SeriesCollection(4).Points(xxx).Select
Selection.Paste
End Sub


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info