• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 342
  • Last Modified:

Adding DataSeries from Array of Numbers (NOT A SHEET)

All,

I am trying to take an array and use this to add a data series to a chart that is already created my code below:

            Dim arr(ArrayLength - 1) As Integer
            Dim j As Integer

            For j = 1 To ArrayLength
                arr(j - 1) = WorksheetName.worksheets(MetricType).range("C" & dataRow).value
            Next

            chartWorkbook.SeriesCollection.Add(source:=

I am not sure how to set the series source to the array.. how do I do this???

or for simple code:
            Dim arr(2) As Integer
           arr={1,1}

            chartWorkbook.SeriesCollection.Add(source:=

THANKS!!!
0
sporenza
Asked:
sporenza
  • 2
1 Solution
 
Bob LearnedCommented:
You should be able to add data to a Series this way:

XValues Property
http://msdn2.microsoft.com/en-us/library/aa215988(office.11).aspx

Charts("Chart1").SeriesCollection(1).XValues = Array(5.0, 6.3, 12.6, 28, 50)

Bob
0
 
sporenzaAuthor Commented:
Bob,

Thanks for the solution but my array already has numbers in it, actually there can be thousands of numbers in it and are filled prior so I can not simply write them out as you shown here..

what I mean is in the example i show the array is actually filled with a loop and the array size is dynamic as well as the values in it...

hope you understand.  THanks for your help!
0
 
Bob LearnedCommented:
That was only an example of using an array.  If you already have the array, then you should be able to assign that to the XValues property.

Bob
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now