activechartseriescollectionindex
Microsoft Office TrainingThe UK's Number 1 for Microsoft Office Training Sitemap add this page to your favourites/bookmarksBookmark page
 
view a printable version of this pagePrintable version
Plus One Google
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

resolvedResolved · High Priority · Version 2007

replyReplyWed 6 Jan 2010, 16:53Delegate jeff said...

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

For upcoming training course dates see: Pricing & availability

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

 

 

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

Excel tip:

Sorting data stored in rows

Primarily Excel is set up to sort data that is stored in columns rather than rows.

It is possible to get Excel to sort data stored in rows however.

Click in the row you want to sort, or select the cells in the rows you wish to sort.

Go to Data - Sort, then go to the Options button in the bottom left corner of the Sort dialogue box.

View all Excel hints and tips

forum postIs it possible to change the word order when creating a new field within a query, eg:

Field content (not seperate columns in the table): "Simon Gardner"

I want it to say "Gardner, Simon" (the table hasn't been normalised). If th..

» Forum post: Word order within a field in a query...


Rate this page:
2.2/5 (213 votes cast)
Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses
Microsoft Certified Partner
Security Seal verified by visa, mastercard securecard

Mini sitemap. These are the main areas of our web site. Full sitemap.

Management training

Professional Skills courses
Project Management Course London
Project Management Courses London
Project Management Training London
Project Management Training
Project Seminar
Project Seminars
Time Management Course London
Time Management London
Time Management Courses London
Time Management Training London
Introduction to Finance course
Assertiveness Skills course
Effective Communications Skills training
Presentation Skills London

Training Formats

Public scheduled courses
On-site training
Closed company courses

Consultancy
Application Development

Blogs

Excel Training
MS Project Training
Microsoft Training Blog

Version differences

Office 2010 vs 2007
MS Project version differences

Training Information

London Computer Training
Computer Training London
Docklands Training Courses
Docklands Training London

Training venues London
Client list
FAQ
Pricing and availability
Course details / Syllabus

Training Articles
Training Information

Microsoft training

Microsoft Office training
& IT Applications

Microsoft Project training
Microsoft Outlook training
Microsoft Powerpoint training
Microsoft Word training
MS Project courses
MS Project training
Outlook courses
PowerPoint courses
PowerPoint training
VBA courses
Word courses
Microsoft.training
(more...)

Excel Training

Excel courses
Excel Training Courses Medway
Autonumber in Excel
Microsoft Excel training
Basic Excel Courses
Basic Excel Course
Basic Excel Training

Interested in MS Access training?

Access courses
Microsoft Access training
Microsoft access courses
Microsoft training access course
Microsoft+access+training
Access courses in london

Training provider

Training providers
IT training companies
IT training providers
Management Training providers
Management Training provider

Event history, feedback results
Events in 2012 · 2011 · 2010 · More

See also

Crystal Reports training