draw chart

D

Dirk Nachbar

I want to draw/amend a chart, but VBA stumbles over the range(cells)
bit, any ideas why?? Player "you" has worksheet 3 and the other
players have the consecutive worksheets.

Dirk

Sub Macro6()
Dim players, round, i
players = 2
round = 10
Charts(1).Activate
ActiveChart.ChartType = xlLineMarkers
' ActiveChart.SeriesCollection(1).XValues =
Worksheets(3).Range(Cells(2, 1), Cells(round + 1, 1))
ActiveChart.SeriesCollection(1).Values =
Worksheets(3).Range(Cells(2, 1), Cells(round + 1, 1))
ActiveChart.SeriesCollection(1).Name = "You"
For i = 2 To players + 3
ActiveChart.SeriesCollection(i).Values = Worksheets(i +
2).Range(Cells(2, 1), Cells(round + 1, 1))
ActiveChart.SeriesCollection(i).Name = "Player" & i
Next i
End Sub
 
J

Jon Peltier

Describe "stumbles". What's the error message (not the error number, because
it's probably 1004).
What is the chart type? Do the intended ranges contain data? Do the series
plot correctly before running the macro?

- Jon
 
J

Jim Cone

Dirk,

"Cells" without a qualifier refers to the active sheet.
Note the dots below...

With Worksheets(3)
..Range(.Cells(2, 1), .Cells(round + 1, 1))
End With
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Dirk Nachbar" <[email protected]>
wrote in message
I want to draw/amend a chart, but VBA stumbles over the range(cells)
bit, any ideas why?? Player "you" has worksheet 3 and the other
players have the consecutive worksheets.
Dirk

Sub Macro6()
Dim players, round, i
players = 2
round = 10
Charts(1).Activate
ActiveChart.ChartType = xlLineMarkers
' ActiveChart.SeriesCollection(1).XValues =
Worksheets(3).Range(Cells(2, 1), Cells(round + 1, 1))
ActiveChart.SeriesCollection(1).Values =
Worksheets(3).Range(Cells(2, 1), Cells(round + 1, 1))
ActiveChart.SeriesCollection(1).Name = "You"
For i = 2 To players + 3
ActiveChart.SeriesCollection(i).Values = Worksheets(i +
2).Range(Cells(2, 1), Cells(round + 1, 1))
ActiveChart.SeriesCollection(i).Name = "Player" & i
Next i
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top