Add Chart with Multiple columns
What can I do to make the code work?
Many thanks
Sub CreateGraph2()
Dim rowNumber As Integer, r(4) As Range
Sheets("Groups For Charting").Range("A1").Select
ActiveCell.FormulaR1C1 = "=COUNT(R4C2:R683C2)"
rowNumber = Sheets("Groups For Charting").Range("A1")
Set r(0) = Sheets("Groups For Charting").Range(Cells(4, 2), Cells(rowNumber, 2))
Set r(1) = Sheets("Groups For Charting").Range(Cells(4, 3), Cells(rowNumber, 3))
Set r(2) = Sheets("Groups For Charting").Range(Cells(4, 4), Cells(rowNumber, 4))
Set r(3) = Sheets("Groups For Charting").Range(Cells(4, 5), Cells(rowNumber, 5))
Set r(4) = Sheets("Groups For Charting").Range(Cells(4, 6), Cells(rowNumber, 6))
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlAreaStacked
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="Chart30"
Sheets("Chart30").Select
ActiveChart.SeriesCollection(1).Values = r(1)
ActiveChart.SeriesCollection(2).Values = r(2)
'''''''I GOT ERROR HERE''''''''
ActiveChart.SeriesCollection(3).Values = r(3)
ActiveChart.SeriesCollection(4).Values = r(4)
ActiveChart.SeriesCollection(4).XValues = r(0)
ActiveChart.ChartArea.Select
ActiveChart.Legend.Select
Selection.Delete
ActiveChart.ChartArea.Select
ActiveChart.ChartTitle.Select
Selection.Delete
End Sub
Recent comments
5 years 34 weeks ago
6 years 20 weeks ago
6 years 32 weeks ago
6 years 35 weeks ago
6 years 36 weeks ago
6 years 42 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago