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

2024-12-25 00:54:19
推荐回答(1个)
回答1:

Sub Macro1()
Dim b As String
b = ActiveSheet.Name
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData Source:=Sheets(b).Range("A:A,B:B"), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:=b
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlRight
ActiveWindow.Visible = False
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData Source:=Sheets(b).Range("A:A,C:C"), _
PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:=b
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlRight
ActiveWindow.Visible = False
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData Source:=Sheets(b).Range("A:A,D:D"), _
PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:=b
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlRight
End Sub