最高分求一个excel录制宏的疑难问题,请高手指教

2024-12-23 06:56:42
推荐回答(3个)
回答1:

下面这个宏可以完成三个图表的制作,缺点是三个图表叠加在一起,需要手工拖到适当位置。
Sub Macro1()
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("D:E"), PlotBy _
:=xlColumns
ActiveChart.SeriesCollection(2).Delete
ActiveChart.SeriesCollection(1).XValues = "=Sheet1!C4"
ActiveChart.SeriesCollection(1).Values = "=Sheet1!C5"
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("F:G"), PlotBy _
:=xlColumns
ActiveChart.SeriesCollection(2).Delete
ActiveChart.SeriesCollection(1).XValues = "=Sheet1!C6"
ActiveChart.SeriesCollection(1).Values = "=Sheet1!C7"
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("H:I"), PlotBy _
:=xlColumns
ActiveChart.SeriesCollection(2).Delete
ActiveChart.SeriesCollection(1).XValues = "=Sheet1!C8"
ActiveChart.SeriesCollection(1).Values = "=Sheet1!C9"
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
End Sub

注:工作表名为“Sheet1”。

回答2:

这里就不想说了,我推荐给你一个网站阿http://club.excelhome.net
我觉得有关excel的问题去那里提问更好。

回答3:

不清楚