ExcelKid_10
Board Regular
- Joined
- Mar 17, 2004
- Messages
- 87
hello-
I have a simple code that I wrote to loop through data line by line to create a column chart. The code stalls out on the .Values line where I try when I try to add the first series....I get a run-time error '1004'. however, after searching numerous times I cannot find what might be causing it....here is my code
Sub UpdateGraphs_NEW()
Dim LastRow As Long
Dim irow, icol As Long
Dim strSourceSheet As String
Dim strGraphSheet As String
strSourceSheet = "NewGraphData"
strGraphSheet = "Graphs"
'Find the last row of data
Sheets(strSourceSheet).Select
LastRow = Range("o65536").End(xlUp).Row
LastRow = LastRow - 2
Sheets(strGraphSheet).ChartObjects("Chart 4").Activate
For i = 1 To LastRow
irow = i + 2
With ActiveChart.SeriesCollection.NewSeries
.Name = Sheets(strSourceSheet).Cells(irow, 15)
.Values = Sheets(strSourceSheet).Range(Cells(irow, 19), Cells(irow, 24))
.XValues = Sheets(strSourceSheet).Range(Cells(3, 48), Cells(8, 48))
End With
Next i
End Sub
Just looking for someone to point me in the right direction...
thanks!!!
EK
I have a simple code that I wrote to loop through data line by line to create a column chart. The code stalls out on the .Values line where I try when I try to add the first series....I get a run-time error '1004'. however, after searching numerous times I cannot find what might be causing it....here is my code
Sub UpdateGraphs_NEW()
Dim LastRow As Long
Dim irow, icol As Long
Dim strSourceSheet As String
Dim strGraphSheet As String
strSourceSheet = "NewGraphData"
strGraphSheet = "Graphs"
'Find the last row of data
Sheets(strSourceSheet).Select
LastRow = Range("o65536").End(xlUp).Row
LastRow = LastRow - 2
Sheets(strGraphSheet).ChartObjects("Chart 4").Activate
For i = 1 To LastRow
irow = i + 2
With ActiveChart.SeriesCollection.NewSeries
.Name = Sheets(strSourceSheet).Cells(irow, 15)
.Values = Sheets(strSourceSheet).Range(Cells(irow, 19), Cells(irow, 24))
.XValues = Sheets(strSourceSheet).Range(Cells(3, 48), Cells(8, 48))
End With
Next i
End Sub
Just looking for someone to point me in the right direction...
thanks!!!
EK