|
你自己的图表太难看了,我没有完全按你的图表做。
(已按你的表格规律自动绘图,请勿随便更改表格式)
图aaa中,你的原图是下边那个,日期挡住线了,我就做成上边那个样式。
图bbb你没有提供原图,我就按我的思路设计了。
- Sub AddNewCharts()
- Dim ch As ChartObject, ws As Worksheet
- Dim lastrow&, lastcol&
- Application.ScreenUpdating = False
- Set ws = Worksheets("Return")
- If ws.ChartObjects.Count > 0 Then ws.ChartObjects.Delete
- lastrow = ws.Cells(Rows.Count, 1).End(xlUp).Row
- lastcol = ws.Cells(2, Columns.Count).End(xlToLeft).Column
- For i = 6 To lastcol Step 5
- Set ch = ws.ChartObjects.Add(ws.Cells(5, i - 4).Left, ws.Cells(5, 1).Top, 360, 215)
- ch.Name = ws.Cells(1, i - 4)
- With ch.Chart
- .ChartType = xlLineMarkers
- .SeriesCollection.NewSeries
- .SeriesCollection(1).Values = ws.Range(ws.Cells(3, i), ws.Cells(lastrow, i))
- .SeriesCollection(1).XValues = ws.Range(ws.Cells(3, 1), ws.Cells(lastrow, 1))
- End With
- With ch.Chart.Axes(xlValue, xlPrimary)
- .CrossesAt = .MinimumScale
- .TickLabels.Font.Size = 8
- .MajorGridlines.Border.ColorIndex = 20
- End With
- With ch.Chart.Axes(xlCategory).TickLabels
- .Font.Size = 8
- .NumberFormatLocal = "yyyy/m/d"
- End With
- With ch.Chart
- .HasTitle = True
- .ChartTitle.Text = ch.Name
- .ChartTitle.Font.Size = 18
- .ChartTitle.Left = 137
- .ChartTitle.Top = 2
- .Legend.Delete
- .PlotArea.Width = 347
- .PlotArea.Left = 0
- .PlotArea.Top = 20
- .PlotArea.Height = 181
- End With
- Next
- Application.ScreenUpdating = True
- MsgBox "绘图完毕"
- End Sub
- Sub AddNewCharts2()
- Dim ch As ChartObject, ws As Worksheet
- Dim lastrow&, lastcol&
- Application.ScreenUpdating = False
- Set ws = Worksheets("Risk")
- If ws.ChartObjects.Count > 0 Then ws.ChartObjects.Delete
- lastrow = ws.Cells(Rows.Count, 1).End(xlUp).Row
- lastcol = ws.Cells(2, Columns.Count).End(xlToLeft).Column
- For i = 2 To lastcol Step 5
- Set ch = ws.ChartObjects.Add(ws.Cells(5, i).Left, ws.Cells(5, 1).Top, 360, 215)
- ch.Name = ws.Cells(1, i)
- With ch.Chart
- .ChartType = xlLineMarkers
- .SeriesCollection.NewSeries
- .SeriesCollection(1).Values = ws.Range(ws.Cells(3, i), ws.Cells(lastrow, i))
- .SeriesCollection(1).XValues = ws.Range(ws.Cells(3, 1), ws.Cells(lastrow, 1))
- .SeriesCollection(1).Name = "市盈率"
- .SeriesCollection(1).AxisGroup = 1
- .SeriesCollection.NewSeries
- .SeriesCollection(2).Values = ws.Range(ws.Cells(3, i + 1), ws.Cells(lastrow, i + 1))
- .SeriesCollection(2).XValues = ws.Range(ws.Cells(3, 1), ws.Cells(lastrow, 1))
- .SeriesCollection(2).Name = "市净率"
- .SeriesCollection(2).AxisGroup = 2
- End With
- With ch.Chart.Axes(xlValue, xlPrimary)
- .CrossesAt = .MinimumScale
- .TickLabels.Font.Size = 8
- .MajorGridlines.Border.ColorIndex = 20
- End With
- With ch.Chart.Axes(xlValue, xlSecondary)
- .CrossesAt = .MinimumScale
- .TickLabels.Font.Size = 8
- End With
- With ch.Chart.Axes(xlCategory).TickLabels
- .Font.Size = 8
- .NumberFormatLocal = "yyyy/m/d"
- End With
- With ch.Chart
- .HasTitle = True
- .ChartTitle.Text = ch.Name
- .ChartTitle.Font.Size = 18
- .ChartTitle.Left = 137
- .ChartTitle.Top = 2
- .PlotArea.Width = 347
- .PlotArea.Left = 0
- .PlotArea.Top = 20
- .PlotArea.Height = 181
- End With
- Next
- Application.ScreenUpdating = True
- MsgBox "绘图完毕"
- End Sub
复制代码
副本Xl0000014.zip
(178.23 KB, 下载次数: 3)
|
评分
-
2
查看全部评分
-
|