#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default draw chart

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default draw chart

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
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Dirk Nachbar" wrote in message
oups.com...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default draw chart

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"
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to draw a line on a chart, and have it move with the chart? manxman Charts and Charting in Excel 5 September 27th 06 09:31 PM
How do I draw chart like car counter? ezzat Charts and Charting in Excel 2 August 30th 06 01:09 PM
Can you draw more than one pie in a chart? LNguyen Charts and Charting in Excel 1 March 21st 06 03:12 AM
Draw a chart kishore Excel Programming 0 May 13th 05 12:07 PM
how do i draw a chart with excel bkhojolita Excel Discussion (Misc queries) 1 April 2nd 05 12:33 AM


All times are GMT +1. The time now is 04:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"