PC Review


Reply
 
 
Dirk Nachbar
Guest
Posts: n/a
 
      25th Jun 2007
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 With Quote
 
 
 
 
Jon Peltier
Guest
Posts: n/a
 
      25th Jun 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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 With Quote
 
Jim Cone
Guest
Posts: n/a
 
      25th Jun 2007
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" <(E-Mail Removed)>
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to draw a line on a chart, and have it move with the chart? =?Utf-8?B?bWFueG1hbg==?= Microsoft Excel Charting 5 27th Sep 2006 09:31 PM
how to draw crosshairs on a chart that go to the height and width of the chart and move with the cursor position? Steve Microsoft C# .NET 1 11th Sep 2006 02:41 PM
Can you draw more than one pie in a chart? =?Utf-8?B?TE5ndXllbg==?= Microsoft Excel Charting 1 21st Mar 2006 03:12 AM
how to draw two type of chart in same chart Zero Microsoft C# .NET 0 6th Jul 2005 05:13 AM
Draw a chart kishore Microsoft Excel Programming 0 13th May 2005 12:07 PM


Features
 

Advertising
 

Newsgroups
 


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