yurble_vn
08-25-2007, 05:06 AM
Hi All,
Please kindly help in how to handle chart data. Always received "Unable to set the Name Values of The Series Class" or "Unable to set the XValues of The Series Class"
Also attach file for you all convenience...
Option Explicit
Sub Set_Source()
Dim icount As Integer
Dim j As Integer
Dim chrtcount As Integer
Dim colcount As Integer
Dim rowcount As Integer
Dim rcount As Integer
With ActiveSheet
chrtcount = .ChartObjects.Count
MsgBox chrtcount
For icount = 1 To chrtcount
For j = 1 To 50
MsgBox .ChartObjects(icount).Name
MsgBox .Name
If .ChartObjects(icount).Name = "Chrt" & j Or .ChartObjects(icount).Name = "NotChrt" & j Then
colcount = .Cells(10 * j - 7, "W")
rowcount = .Cells(10 * j - 7, "V")
'set data
.ChartObjects(icount).Chart.SetSourceData Source:=.Range(.Cells(10 * j - 6, "X"), .Cells(10 * j - 7 + rowcount, 23 + colcount)), _
PlotBy:=xlRows
For rcount = 1 To rowcount
.ChartObjects(icount).Chart.SeriesCollection(rcount).Name = "='" & .Name & "'!R " & 10 * j - 7 + rcount & "C23"
Next
.ChartObjects(icount).Chart.SeriesCollection(1).XValues = "='" & .Name & "'!R " & 10 * j - 7 & "C24:R" & 10 * j - 7 & "C" & (23 + colcount)
End If
Next
Next
End With
End Sub
Please kindly help in how to handle chart data. Always received "Unable to set the Name Values of The Series Class" or "Unable to set the XValues of The Series Class"
Also attach file for you all convenience...
Option Explicit
Sub Set_Source()
Dim icount As Integer
Dim j As Integer
Dim chrtcount As Integer
Dim colcount As Integer
Dim rowcount As Integer
Dim rcount As Integer
With ActiveSheet
chrtcount = .ChartObjects.Count
MsgBox chrtcount
For icount = 1 To chrtcount
For j = 1 To 50
MsgBox .ChartObjects(icount).Name
MsgBox .Name
If .ChartObjects(icount).Name = "Chrt" & j Or .ChartObjects(icount).Name = "NotChrt" & j Then
colcount = .Cells(10 * j - 7, "W")
rowcount = .Cells(10 * j - 7, "V")
'set data
.ChartObjects(icount).Chart.SetSourceData Source:=.Range(.Cells(10 * j - 6, "X"), .Cells(10 * j - 7 + rowcount, 23 + colcount)), _
PlotBy:=xlRows
For rcount = 1 To rowcount
.ChartObjects(icount).Chart.SeriesCollection(rcount).Name = "='" & .Name & "'!R " & 10 * j - 7 + rcount & "C23"
Next
.ChartObjects(icount).Chart.SeriesCollection(1).XValues = "='" & .Name & "'!R " & 10 * j - 7 & "C24:R" & 10 * j - 7 & "C" & (23 + colcount)
End If
Next
Next
End With
End Sub