|
适用于 2003 版:- Option Explicit
- Private Sub CommandButton1_Click()
- RefreshChart
- [j4].Select
- End Sub
- Private Sub Worksheet_Calculate()
- RefreshChart
- End Sub
- Sub RefreshChart()
- Dim i%, j%, c, D%(0 To 6, 0 To 4), SD(1 To 6), cObject As ChartObject, xChart As chart
- For Each c In Sheets("解答").ChartObjects
- If c.Name = "xjdChart" Then Set cObject = c: Set xChart = cObject.chart
- Next
- If cObject Is Nothing Then
- Set cObject = Sheets("解答").ChartObjects.Add(100, 30, 340, 220)
- cObject.Name = "xjdChart"
- Set xChart = cObject.chart
- With xChart.SeriesCollection: .NewSeries: .NewSeries: .NewSeries: .NewSeries: End With
- With xChart
- .PlotArea.Width = 300
- .PlotArea.Height = 200
- .PlotArea.Border.ColorIndex = xlNone
- .PlotArea.Interior.ColorIndex = xlNone
- .ChartGroups(1).Overlap = 100
- .ChartGroups(1).GapWidth = 0
- .SeriesCollection(1).Border.ColorIndex = 15
- .SeriesCollection(1).Interior.ColorIndex = xlNone
- .HasLegend = False
- With .Axes(xlValue)
- .MinimumScale = 0
- .MaximumScale = 4
- .MajorUnit = 1
- .HasMajorGridlines = True
- .MajorGridlines.Border.ColorIndex = 15
- .Border.LineStyle = xlNone
- End With
- With .Axes(xlCategory)
- .HasMajorGridlines = True
- .MajorGridlines.Border.ColorIndex = 15
- .Border.LineStyle = xlNone
- .TickLabels.Font.FontStyle = "加粗"
- End With
- End With
- End If
-
- For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
- D(Cells(i, 1), Cells(i, 2)) = D(Cells(i, 1), Cells(i, 2)) + 1
- Next
- For j = 1 To 4
- For i = 1 To 6: SD(i) = IIf(D(i, j), j, 0): Next
- xChart.SeriesCollection(5 - j).Values = "={" & Join(SD, ",") & "}"
- For i = 1 To 6
- With xChart.SeriesCollection(5 - j).Points(i)
- .Border.LineStyle = xlNone
- .Fill.TwoColorGradient Style:=msoGradientDiagonalDown, Variant:=1
- .Fill.ForeColor.SchemeColor = IIf(D(i, j) > 1, 3, 5)
- .Fill.BackColor.SchemeColor = IIf(D(i, j) > 1, 36, 34)
- End With
- Next
- Next
- End Sub
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?免费注册
x
评分
-
1
查看全部评分
-
|