我想制作每月占用机器的柱形图。我有这个数据库:
我正在使用此代码制作图表:
private sub
rng1 = folhaexcel5.Range("B2:M2", "B3:M3")
grafico = folhaexcel5.Shapes.AddChart(xlColumns).Chart
grafico.SetSourceData(Source:=rng1)
grafico.HasTitle = True
grafico.ChartTitle.Characters.Text = "Occupation Rate of Machines"
grafico.Axes(XlAxisType.xlValue).MaximumScale = 100
grafico.Axes(XlAxisType.xlValue).HasTitle = True
grafico.Axes(XlAxisType.xlValue).axistitle.characters.text = "Occupation Rate (%)"
grafico.HasLegend = False
folhaexcel5.ChartObjects(1).Top = folhaexcel5.Range("p3").Top
folhaexcel5.ChartObjects(1).left = folhaexcel5.Range("p3").Left
folhaexcel5.ChartObjects(1).height = 300
folhaexcel5.ChartObjects(1).width = 1000
grafico.SeriesCollection(1).Interior.Color = Color.FromArgb(0, 124, 208)
grafico.SeriesCollection(1).Border.Color = Color.FromArgb(0, 55, 92)
End sub
当我运行它时,图表会添加到excel文件中,但它是空白的。当我点击图表查看所选数据时,会向我显示:
我想将第2行作为x轴,将第3行作为y值。但似乎我无法选择这两条线。有人可以帮帮我吗?