VBA自动生成图表.docVIP

  • 10
  • 0
  • 约1.8千字
  • 约 2页
  • 2020-02-09 发布于广东
  • 举报
Sub BatchPlot() ? ? Dim i ? ? For i = 2 To 10 ? ?? ???Charts.Add ? ?? ???增加一个图表 ? ?? ???ActiveChart.ChartType = xlLineMarkers ? ?? ???设置图表类型为折线图 ? ?? ???ActiveChart.SetSourceData Source:=Sheets(批量绘图).Range(A1:D1, A i :D i), PlotBy:=xlRows ? ?? ???设置图表的数据源 ? ?? ???ActiveChart.Location Where:=xlLocationAsObject, Name:=批量绘图 ? ?? ???设置图表的位置为当前工作表中 ? ?? ???ActiveChart.Parent.Top = 220 * (i - 2) ? ?? ???设置图表的上下间隔为220磅 ? ?? ???ActiveChart.Parent.Left = 456 ? ?? ???设置图表距左为456磅 ? ? Next i End Sub 以完成的 Sub BatchPlot() Set ab = Range(H7:Q23) 生成图表的位置 Set ab = Range(Cells(7, 8), Cells(23, 17)) Set bbb = ActiveSheet.ChartObjects.Add(0, 0, 0, 0) bbb.Chart.ChartType = xlLineMarkers 折线图 bbb.Chart.SetSourceData Source:=Sheets(Sheet1).Range(C1:C128) 数据源 ActiveChart.Location Where:=xlLocationAsObject, Name:=批量绘图 设置图表的位置为当前工作表中 With bbb .Top = ab.Top .Left = ab.Left .Width = ab.Width .Height = ab.Height End With End Sub Sub BatchPlot() Dim i As Long For i = 1 To 42988 Step 21 i = 1 Set ab = Range(Cells(i + 1, 9), Cells(i + 20, 17)) Set ab = Range(Cells(9, 2), Cells(15, 21)) Set bbb = ActiveSheet.ChartObjects.Add(0, 0, 0, 0) bbb.Chart.ChartType = xlLineMarkers 折线图 bbb.Chart.SetSourceData Source:=Sheets(Sheet2).Range(Cells(i + 1, 7), Cells(i + 20, 7)) 数据源 bbb.Chart.SetSourceData Source:=Sheets(Sheet1).Range(Cells(7, 2), Cells(7, 21)) With bbb .Top = ab.Top .Left = ab.Left .Width = ab.Width .Height = ab.Height End With Next End Sub

文档评论(0)

1亿VIP精品文档

相关文档