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 41 weeks ago
6 years 27 weeks ago
6 years 39 weeks ago
6 years 42 weeks ago
6 years 43 weeks ago
6 years 48 weeks ago
7 years 4 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago