Create Chart from Array data and not range

后端 未结 2 1101
情深已故
情深已故 2020-12-03 03:20

is it possible to create a Chart (e.g. Double Y-Axis Line Chart) not from Ranges, but from Array data? If so, how?

2条回答
  •  攒了一身酷
    2020-12-03 03:48

    Yes. You can assign arrays to the XValues and Values properties of a Series object on a chart. Example:

    Dim c As Chart
    Dim s As Series
    Dim myData As Variant
    
    Set c = ActiveChart ' Assumes a chart is currently active in Excel...
    Set s = c.SeriesCollection(1)
    
    myData = Array(9, 6, 7, 1) ' or whatever
    s.Values = myData
    

提交回复
热议问题