activechartseriescollectionindex
Microsoft Office TrainingThe UK's Number 1 for Microsoft Office Training add this page to your favourites/bookmarksBookmark page

view a printable version of this pagePrintable version
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel Training and help » ActiveChart.SeriesCollection(index) index as a function

ActiveChart.SeriesCollection(index) index as a function

The UK's most regular instructor-led training courses.
Training information: advanced excel seminar training · Excel course london · Microsoft Excel Training UK
See also · excel-courses-london · excel courses in london · excel microsoft training

resolvedResolved · High Priority · Version 2007

No ranking yet
5 posts
replyReplyWed 6 Jan 2010, 16:53Delegate jeff said...

jeff has attended:
Excel VBA Intro Intermediate course

ActiveChart.SeriesCollection(index) index as a function

Hi I have two questions:
1.) Is it possible to have the index part of an ActiveChart.SeriesCollection(index) as a function i.e. "n + 1" or a integer or variable that is equal to a function. I have a VBA script that uses for loops to add series's of data to a chart through the script. I think I will be able to simplify my script if I can do this.

2.) The plot is an xy scatter and I would like the values of the dataseries to be a collection of points that are not all next to each other. is this possible? I have found a work around by creating an array from the values but ideally the char would be pointing at the cells in the sheet.

I hope I have explained my questions clearly.

Thanks very much in advance.

Script below

Sub CreateChartScript()

Dim n As Integer
Dim t As Integer
Dim j As Integer

ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlXYScatterLines
For n = 1 To 7 'fixed for 7 columns, 10 to 70 deg C, if adding more columns adjust.
ActiveChart.SeriesCollection.NewSeries
With ActiveChart.SeriesCollection(n)
.MarkerStyle = xlMarkerStyleNone
.Border.ColorIndex = 1
.Border.Weight = xlThin
.Name = Sheets("Cont RH").Cells(1, 2 + n)
.XValues = Range(Sheets("Cont RH").Cells(2, 2), Sheets("Cont RH").Cells(16, 2))
.Values = Range(Sheets("Cont RH").Cells(2, 2 + n), Sheets("Cont RH").Cells(16, 2 + n))

End With
Next

For n = n To 9 '2 loops
ActiveChart.SeriesCollection.NewSeries
With ActiveChart.SeriesCollection(n)
.MarkerStyle = xlMarkerStyleNone
.Border.ColorIndex = n
.Border.Weight = xlThin
.Name = n 'ActiveSheet.Cells(2, 2)
.XValues = Array(Sheets("Populated sheet").Cells(3 + (n - 7), 2), Sheets("Populated sheet").Cells(6 + (n - 7), 2), Sheets("Populated sheet").Cells(9 + (n - 7), 2))
.Values = Array(Sheets("Populated sheet").Cells(3 + (n - 7), 3), Sheets("Populated sheet").Cells(6 + (n - 7), 3), Sheets("Populated sheet").Cells(9 + (n - 7), 3))

End With
Next

For n = n To 11 '2 loops
ActiveChart.SeriesCollection.NewSeries
With ActiveChart.SeriesCollection(n)
.MarkerStyle = xlMarkerStyleNone
.Border.ColorIndex = n
.Border.Weight = xlThin
.Name = n 'ActiveSheet.Cells(2, 2)
.XValues = Array(Sheets("Populated sheet").Cells(3 + (n - 9), 4), Sheets("Populated sheet").Cells(6 + (n - 9), 4), Sheets("Populated sheet").Cells(9 + (n - 9), 4))
.Values = Array(Sheets("Populated sheet").Cells(3 + (n - 9), 5), Sheets("Populated sheet").Cells(6 + (n - 9), 5), Sheets("Populated sheet").Cells(9 + (n - 9), 5))

End With
Next

With ActiveChart
.Axes(xlCategory).MinimumScale = 0
.Axes(xlCategory).MaximumScale = 100
.Axes(xlCategory).MajorUnit = 10

.Axes(xlValue).MinimumScale = -40
.Axes(xlValue).MaximumScale = 100
.Axes(xlValue).MajorUnit = 10

.SetElement (msoElementChartTitleCenteredOverlay)
.ChartTitle.Text = "test"
End With
End Sub

Excel Advanced 1 day course
Version Date Location Places
available
Book Next place rate (£)
Pay by
Card
Pay by
Invoice
2003 Wed 24 Mar 2010 Limehouse 7 Book now £212 £217
2007 Fri 26 Mar 2010 Rochester (Hoo) 0 FULL    
2007 Mon 29 Mar 2010 Bloomsbury 2 Book now £235 £240
2003 Wed 31 Mar 2010 Southwark 7 Book now £219 £224
2007 Tue 6 Apr 2010 Limehouse 5 Book now £235 £240
2007 Fri 9 Apr 2010 Southwark 8 Book now £193 £198
Full Schedule: See all 69 Excel Advanced course dates.
Bookings currently available until 22nd December 2010.

Gold
213 posts
replyReplyFri 8 Jan 2010, 15:40Trainer Jacob said...

RE: ActiveChart.SeriesCollection(index) index as a function

Hi Jeff

With regards to your post we have had a look at it and addressing it in 2 parts:

1) Much of what you are trying to do is covered on our Excel VBA Advanced course, click here for details.

2) We can assist with this but will need to see your working files to advise on a solution and amount of work involved.

It is possible to create a bespoke one-to-one training event for you to be trained to develop a solution for your current requirements and enable you to tackle future requirements as well.

Your requests in this instance are beyond the scope of the forum however if you wish to discuss the above options further please reply to my email directly.

Kind regards
Jacob


Related articles

· How to Create Better Excel Spreadsheets: Part Two
· Using Excel In Any Condition
· Benefits of learning about Excel charts
· A Beginners Guide To Formulas In Excel
· Excel in the Home Office

Please browse our web site to find out more about
advanced excel seminar training and other Microsoft training courses.

Excel tip:

Selecting your working range

In excel if you have an area you want to highlight, press Ctrl + * or Ctrl+Shift+8 (to get the *). This will select your working range.

View all Excel hints and tips


Rate this page:
2.1/5 (108 votes cast)
Institute of IT Training - Accredited Training Provider ILM
Microsoft Certified Partner
Microsoft Office Specialist Authorised Testing Centre (MOS and MCAS)

Prodigy Platinum Learning Partner

Institute of IT Training - Accredited Training Provider
McAfee Secure sites help keep you safe from identity theft, credit card fraud, spyware, spam, viruses and online scams
Association of Computer Trainers verified by visa, mastercard securecard