craigwg
08-13-2010, 01:40 PM
I am making a Scrabble score tracker and I have some charts I need to create dynamically. I also need to adjust the colors but after a few hours of research I still can't successfully do it. Here is the code I have:
Sub createScoreChart()
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlLine
ActiveChart.PlotVisibleOnly = False
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).Name = "='Scrabble'!$H$7"
ActiveChart.SeriesCollection(1).Values = "='Scrabble'!$B$10:$S$10"
ActiveChart.SeriesCollection(1).Line.Color = "red"
ActiveChart.SeriesCollection(1).Interior.ColorIndex = 5 ''This is the line in question
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(2).Name = "='Scrabble'!$H$11"
ActiveChart.SeriesCollection(2).Values = "='Scrabble'!$B$14:$S$14"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(3).Name = "='Scrabble'!$H$15"
ActiveChart.SeriesCollection(3).Values = "='Scrabble'!$B$18:$S$18"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(4).Name = "='Scrabble'!$H$19"
ActiveChart.SeriesCollection(4).Values = "='Scrabble'!$B$22:$S$22"
End Sub
Any help would be great on this. I realize I need to make my code more efficient and use with statements. I'll put those in later. Gotta get it working first, right?
Sub createScoreChart()
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlLine
ActiveChart.PlotVisibleOnly = False
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).Name = "='Scrabble'!$H$7"
ActiveChart.SeriesCollection(1).Values = "='Scrabble'!$B$10:$S$10"
ActiveChart.SeriesCollection(1).Line.Color = "red"
ActiveChart.SeriesCollection(1).Interior.ColorIndex = 5 ''This is the line in question
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(2).Name = "='Scrabble'!$H$11"
ActiveChart.SeriesCollection(2).Values = "='Scrabble'!$B$14:$S$14"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(3).Name = "='Scrabble'!$H$15"
ActiveChart.SeriesCollection(3).Values = "='Scrabble'!$B$18:$S$18"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(4).Name = "='Scrabble'!$H$19"
ActiveChart.SeriesCollection(4).Values = "='Scrabble'!$B$22:$S$22"
End Sub
Any help would be great on this. I realize I need to make my code more efficient and use with statements. I'll put those in later. Gotta get it working first, right?