简体   繁体   中英

Excel VBA - Set SeriesCollection = 2D array

I have a two dimensional array as follows

Dim plot() As Double
ReDim plot(0 to 1, 0 to arryLength) ' arryLength is some integer value

Dimension '0' refers to the x-axis values of a plot and dimension '1' refers to the y-axis values. I need to use this array to set the values on a pre-existing plot. I know with a 1D array you can do something like

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(1).XValues = xaxis()
ActiveChart.SeriesCollection(1).Values = yaxis()

How do I set it set .XValues = plot(@ Dimension 0) and .Values = plot(@ Dimension 1) ?

Maybe:

With ActiveSheet.ChartObjects("chart 1").Chart
    .SeriesCollection(1).XValues = Application.Transpose(Application.Index(plot, 0, 1))
    .SeriesCollection(1).Values = Application.Transpose(Application.Index(plot, 0, 2))
End With

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM