Hi
I'm trying to do a simple loop which creates charts based on an ID number. I recorded a macro and has tried to modify it but am having trouble defining the correct reange when settign the data source.
Here is my code:
Sub LapseGraphs()
Dim i As Long, m As Integer, n As Integer
m = 2 'row number start of current block
For i = 2 To 60000
If Cells(i, 1) <> Cells(i + 1, 1) Then
n = i
Range(Cells(m, 2), Cells(n, 3)).Select
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData Source:=Sheets("Lapsed NSL").Range(Cells(m, 2), Cells(n, 3)), _ 'getting run time error 1004 at this line?
PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Lapsed NSL"
m = n + 1
End If
Next i
End Sub
This results at a run time error 1004.
Any help debugging this would be appreciated.
Bookmarks