参考:http://club.excelhome.net/thread-480025-1-1.html
1 '--------------------------------------------------------Module1-------------------------------------------------------- 2 Sub Macro1() 3 ActiveSheet.Range("B1:B40").Select 4 ActiveSheet.Shapes.AddChart.Select 5 ActiveChart.ChartType = xlXYScatter 6 ActiveChart.SetSourceData Source:=Range("'Sheet5'!$A$1:$B$40") 7 With ActiveChart 8 .HasTitle = True '为图表设置标题 9 With .ChartTitle 10 .Text = "交会图版" 11 .Font.Name = "宋体" 12 .Font.Size = 15 13 .Font.ColorIndex = 5 14 .Top = 5 15 .Left = 150 16 End With 17 With .Axes(xlCategory) '为图表设置横坐标 18 .HasTitle = True 19 .AxisTitle.Text = "统计含量" 20 .AxisTitle.Font.Name = "宋体" 21 .AxisTitle.Font.Size = 12 22 .AxisTitle.Font.Bold = False 23 .AxisTitle.Font.ColorIndex = 1 24 .MinimumScale = 0 25 .MaximumScale = 60 26 End With 27 With .Axes(xlValue) '为图表设置纵坐标 28 .HasTitle = True 29 .AxisTitle.Text = "百分数" 30 .AxisTitle.Font.Name = "宋体" 31 .AxisTitle.Font.Size = 12 32 .AxisTitle.Font.Bold = False 33 .AxisTitle.Font.ColorIndex = 1 34 .MinimumScale = 0 35 .MaximumScale = 80 36 End With 37 .HasLegend = True '为图表设置图例 38 With .Legend 39 .Position = xlLegendPositionRight 40 End With 41 End With 42 End Sub
参考:http://club.excelhome.net/thread-480025-1-1.html