简体   繁体   English

Excel VBA-Set SeriesCollection = 2D数组

[英]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. 尺寸“ 0”是指绘图的x轴值,尺寸“ 1”是指y轴值。 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) ? 如何设置.XValues = plot(@ Dimension 0).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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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