lundi 30 mars 2015

Plot chart for each row

I am a new learner of VBA. I would like to plot chart for each row whereby if there is 20 rows in the table, there will be 20 charts. The number of rows and columns are dynamics. I get parameter error at the part defining series collection and I can't figure out the solutions.



Set cht = Sheets(wsName).Shapes.AddChart.Chart
'sets the chart type
cht.ChartType = xlLine

For a = row To totalRow
With Sheets(wsName)
'now the line chart is added...setting its data source here
cht.SetSourceData Source:=.Range(.Cells(a, ColFirst), .Cells(a, ColLast))
cht.SeriesCollection.NewSeries
cht.SeriesCollection(a).XValues = .Range(.Cells(a, ColFirst), .Cells(a, ColLast))
cht.SeriesCollection(a).Values = .Range(.Cells(4, ColFirst), .Cells(4, ColLast))
End With
Next

Aucun commentaire:

Enregistrer un commentaire