你通过什么形式让它显示呢?还是想做些其他的应用?
把下面的代码复制到窗体里面,初始化下ChartSpace。这个控件比较老,跟excel里面的图表的变现还不太一样
Private Sub UserForm_Initialize()
'设置控件
With Me.ChartSpace1
.Clear
.Border.Color = RGB(0, 0, 255)
.Border.Weight = 3
'设置图表
With .Charts.Add
.HasTitle = True
.Title.Caption = "图表"
.Title.Font.Name = "黑体"
.Title.Font.Size = 16
.Interior.Color = RGB(243, 243, 243)
.Type = chChartTypeLineMarkers '折线图
.Axes(0).Font.Name = "Airal"
.Axes(0).Font.Size = 10
.Axes(0).Font.Color = RGB(103, 103, 103)
.PlotArea.Border.Color = RGB(103, 103, 103)
.PlotArea.Border.Weight = 2
'设置系列
With .SeriesCollection.Add
.Line.Color = RGB(139, 186, 0)
.Line.Weight = 3
.Interior.Color = RGB(255, 240, 217)
.Border.Color = RGB(0, 0, 255)
.Marker.Style = chMarkerStyleCircle
'设置系列数据
x = [Transpose(A2:A13)]
y = [Transpose(B2:B13)]
.SetData chDimCategories, chDataLiteral, x
.SetData chDimValues, chDataLiteral, y
End With
End With
End With
End Sub