宏抛出错误,但有时只是

时间:2016-06-29 06:16:14

标签: vba charts

我有一个VBA代码,它首先删除所有图表并创建新图表来刷新图表。当我运行一次或两次代码时,一切都很好。但是当我第三次运行相同的代码时,它不起作用并抛出错误。它在这一行引发错误:ActiveChart.SeriesCollection(1).Points(6).Select

Sub Chart1()

    'deleting charts

    Dim ws As Worksheet
Dim c

    For Each ws In ActiveWorkbook.Worksheets
        For Each c In ws.ChartObjects
            c.Delete
        Next
    Next

    Dim Shp As Shape

For Each Shp In ActiveSheet.Shapes
    If Not (Shp.Type = msoOLEControlObject Or Shp.Type = msoFormControl) Then Shp.Delete
Next Shp    

    ActiveSheet.Shapes.AddShape(msoShapeRoundedRectangle, 38.25, 9.75, 288.75, 90). _
        Select
    Selection.ShapeRange.Fill.Visible = msoFalse
    Selection.ShapeRange.TextFrame2.TextRange.Font.Size = 14
    Selection.ShapeRange.TextFrame2.TextRange.ParagraphFormat.Alignment = _
        msoAlignCenter
    Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = "Choose Student"
    With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 14). _
        ParagraphFormat
        .FirstLineIndent = 0
        .Alignment = msoAlignCenter
    End With
    With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 6).Font
        .NameComplexScript = "+mn-cs"
        .NameFarEast = "+mn-ea"
        .Fill.Visible = msoTrue
        .Fill.ForeColor.RGB = RGB(0, 0, 0)
        .Fill.Transparency = 0
        .Fill.Solid
        .Size = 14
        .Name = "+mn-lt"
    End With
    With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(7, 8).Font
        .BaselineOffset = 0
        .NameComplexScript = "+mn-cs"
        .NameFarEast = "+mn-ea"
        .Fill.Visible = msoTrue
        .Fill.ForeColor.RGB = RGB(0, 0, 0)
        .Fill.Transparency = 0
        .Fill.Solid
        .Size = 14
        .Name = "+mn-lt"
    End With
    Selection.ShapeRange.TextFrame2.TextRange.Font.Bold = msoTrue

   Dim r As Range
For Each r In Sheets("Data").Range("AD4:AM9")
    If IsError(r) Then
        MsgBox "Data not found. Please check selection"
        Exit Sub
    End If
Next

    'first charts

    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.ChartType = xlDoughnut

    With ActiveChart.Parent
         .Height = 144
         .Width = 144
         .Top = 120
         .Left = 40
    End With

    ActiveChart.SetSourceData Source:=Sheets("Data").Range("Z4:AA9")
    ActiveChart.Legend.Select
    Selection.Delete

    ActiveChart.SeriesCollection(1).Select
    ActiveChart.ChartGroups(1).FirstSliceAngle = 270
    ActiveChart.PlotArea.Select
    ActiveChart.SeriesCollection(1).Select
    ActiveChart.SeriesCollection(1).Points(6).Select
    Selection.Format.Fill.Visible = msoFalse
    ActiveChart.SeriesCollection(1).Points(2).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(255, 0, 0)
        .Transparency = 0
        .Solid
    End With
    ActiveChart.SeriesCollection(1).Points(3).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(255, 192, 0)
        .Transparency = 0
        .Solid
    End With
    ActiveChart.SeriesCollection(1).Points(4).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(146, 208, 80)
        .Transparency = 0
        .Solid
    End With
    ActiveChart.SeriesCollection(1).Points(5).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(0, 176, 80)
        .Transparency = 0
        .Solid
    End With
    ActiveChart.ChartArea.Border.LineStyle = xlNone

    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.ChartType = xlPie

    With ActiveChart.Parent
         .Height = 144
         .Width = 144
         .Top = 120
         .Left = 40
    End With

    ActiveChart.SetSourceData Source:=Sheets("Data").Range("AD4:AD6")
    ActiveChart.Legend.Select
    Selection.Delete
    ActiveChart.SeriesCollection(1).Select
    ActiveChart.SeriesCollection(1).Points(3).Select
    Selection.Format.Fill.Visible = msoFalse
    ActiveChart.SeriesCollection(1).Points(1).Select
    Selection.Format.Fill.Visible = msoFalse
    ActiveChart.SeriesCollection(1).Points(3).Select
    ActiveChart.SeriesCollection(1).Points(2).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.ObjectThemeColor = msoThemeColorText1
        .ForeColor.TintAndShade = 0
        .ForeColor.Brightness = 0
        .Transparency = 0
        .Solid
    End With
    ActiveChart.ChartGroups(1).FirstSliceAngle = 270
    ActiveChart.ChartArea.Select

    ActiveChart.ChartArea.Border.LineStyle = xlNone
    ActiveChart.ChartArea.Fill.Visible = False        

    ActiveChart.Shapes.AddShape(msoShapeOval, 58.25, 61.6250393701, 25.5, 25.5). _
        Select
    Selection.ShapeRange.IncrementLeft -3.75
    Selection.ShapeRange.IncrementTop -5.25
    Selection.ShapeRange.Fill.Visible = msoFalse  
    Selection.Characters.Text = Range("Data!AD9").Value

    With Selection.ShapeRange.TextFrame2.TextRange.Font.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(0, 0, 0)
        .Transparency = 0
        .Solid
    End With        

    Selection.ShapeRange.TextFrame2.MarginLeft = 0
    Selection.ShapeRange.TextFrame2.MarginRight = 0
    Selection.ShapeRange.TextFrame2.MarginTop = 0
    Selection.ShapeRange.TextFrame2.MarginBottom = 0
    Selection.ShapeRange.TextFrame2.VerticalAnchor = msoAnchorMiddle
    Selection.ShapeRange.TextFrame2.TextRange.ParagraphFormat.Alignment = _
        msoAlignCenter
    Selection.ShapeRange.TextFrame2.TextRange.ParagraphFormat.Alignment = _
        msoAlignCenter

    'second charts


    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.ChartType = xlDoughnut

    With ActiveChart.Parent
         .Height = 144
         .Width = 144
         .Top = 120
         .Left = 200
    End With

    ActiveChart.SetSourceData Source:=Sheets("Data").Range("Z4:AA9")
    ActiveChart.Legend.Select
    Selection.Delete

    ActiveChart.SeriesCollection(1).Select
    ActiveChart.ChartGroups(1).FirstSliceAngle = 270
    ActiveChart.PlotArea.Select
    ActiveChart.SeriesCollection(1).Select
    ActiveChart.SeriesCollection(1).Points(6).Select
    Selection.Format.Fill.Visible = msoFalse
    ActiveChart.SeriesCollection(1).Points(2).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(255, 0, 0)
        .Transparency = 0
        .Solid
    End With
    ActiveChart.SeriesCollection(1).Points(3).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(255, 192, 0)
        .Transparency = 0
        .Solid
    End With
    ActiveChart.SeriesCollection(1).Points(4).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(146, 208, 80)
        .Transparency = 0
        .Solid
    End With
    ActiveChart.SeriesCollection(1).Points(5).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(0, 176, 80)
        .Transparency = 0
        .Solid
    End With
    ActiveChart.ChartArea.Border.LineStyle = xlNone        

    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.ChartType = xlPie

    With ActiveChart.Parent
         .Height = 144
         .Width = 144
         .Top = 120
         .Left = 200
    End With

    ActiveChart.SetSourceData Source:=Sheets("Data").Range("AG4:AG6")
    ActiveChart.Legend.Select
    Selection.Delete
    ActiveChart.SeriesCollection(1).Select
    ActiveChart.SeriesCollection(1).Points(3).Select
    Selection.Format.Fill.Visible = msoFalse
    ActiveChart.SeriesCollection(1).Points(1).Select
    Selection.Format.Fill.Visible = msoFalse
    ActiveChart.SeriesCollection(1).Points(3).Select
    ActiveChart.SeriesCollection(1).Points(2).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.ObjectThemeColor = msoThemeColorText1
        .ForeColor.TintAndShade = 0
        .ForeColor.Brightness = 0
        .Transparency = 0
        .Solid
    End With
    ActiveChart.ChartGroups(1).FirstSliceAngle = 270
    ActiveChart.ChartArea.Select

    ActiveChart.ChartArea.Border.LineStyle = xlNone
    ActiveChart.ChartArea.Fill.Visible = False


    ActiveChart.Shapes.AddShape(msoShapeOval, 58.25, 61.6250393701, 25.5, 25.5). _
        Select
    Selection.ShapeRange.IncrementLeft -3.75
    Selection.ShapeRange.IncrementTop -5.25
    Selection.ShapeRange.Fill.Visible = msoFalse      

    Selection.Characters.Text = Range("Data!AG9").Value

    With Selection.ShapeRange.TextFrame2.TextRange.Font.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(0, 0, 0)
        .Transparency = 0
        .Solid
    End With        

    Selection.ShapeRange.TextFrame2.MarginLeft = 0
    Selection.ShapeRange.TextFrame2.MarginRight = 0
    Selection.ShapeRange.TextFrame2.MarginTop = 0
    Selection.ShapeRange.TextFrame2.MarginBottom = 0
    Selection.ShapeRange.TextFrame2.VerticalAnchor = msoAnchorMiddle
    Selection.ShapeRange.TextFrame2.TextRange.ParagraphFormat.Alignment = _
        msoAlignCenter
    Selection.ShapeRange.TextFrame2.TextRange.ParagraphFormat.Alignment = _
        msoAlignCenter

 'third charts


    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.ChartType = xlDoughnut

    With ActiveChart.Parent
         .Height = 144
         .Width = 144
         .Top = 120
         .Left = 360
    End With

    ActiveChart.SetSourceData Source:=Sheets("Data").Range("Z4:AA9")
    ActiveChart.Legend.Select
    Selection.Delete

    ActiveChart.SeriesCollection(1).Select
    ActiveChart.ChartGroups(1).FirstSliceAngle = 270
    ActiveChart.PlotArea.Select
    ActiveChart.SeriesCollection(1).Select
    ActiveChart.SeriesCollection(1).Points(6).Select
    Selection.Format.Fill.Visible = msoFalse
    ActiveChart.SeriesCollection(1).Points(2).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(255, 0, 0)
        .Transparency = 0
        .Solid
    End With
    ActiveChart.SeriesCollection(1).Points(3).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(255, 192, 0)
        .Transparency = 0
        .Solid
    End With
    ActiveChart.SeriesCollection(1).Points(4).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(146, 208, 80)
        .Transparency = 0
        .Solid
    End With
    ActiveChart.SeriesCollection(1).Points(5).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(0, 176, 80)
        .Transparency = 0
        .Solid
    End With
    ActiveChart.ChartArea.Border.LineStyle = xlNone        

    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.ChartType = xlPie

    With ActiveChart.Parent
         .Height = 144
         .Width = 144
         .Top = 120
         .Left = 360
    End With

    ActiveChart.SetSourceData Source:=Sheets("Data").Range("AJ4:AJ6")
    ActiveChart.Legend.Select
    Selection.Delete
    ActiveChart.SeriesCollection(1).Select
    ActiveChart.SeriesCollection(1).Points(3).Select
    Selection.Format.Fill.Visible = msoFalse
    ActiveChart.SeriesCollection(1).Points(1).Select
    Selection.Format.Fill.Visible = msoFalse
    ActiveChart.SeriesCollection(1).Points(3).Select
    ActiveChart.SeriesCollection(1).Points(2).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.ObjectThemeColor = msoThemeColorText1
        .ForeColor.TintAndShade = 0
        .ForeColor.Brightness = 0
        .Transparency = 0
        .Solid
    End With
    ActiveChart.ChartGroups(1).FirstSliceAngle = 270
    ActiveChart.ChartArea.Select        
    ActiveChart.ChartArea.Border.LineStyle = xlNone
    ActiveChart.ChartArea.Fill.Visible = False


    ActiveChart.Shapes.AddShape(msoShapeOval, 58.25, 61.6250393701, 25.5, 25.5). _
        Select
    Selection.ShapeRange.IncrementLeft -3.75
    Selection.ShapeRange.IncrementTop -5.25
    Selection.ShapeRange.Fill.Visible = msoFalse      

    Selection.Characters.Text = Range("Data!AJ9").Value

    With Selection.ShapeRange.TextFrame2.TextRange.Font.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(0, 0, 0)
        .Transparency = 0
        .Solid
    End With        

    Selection.ShapeRange.TextFrame2.MarginLeft = 0
    Selection.ShapeRange.TextFrame2.MarginRight = 0
    Selection.ShapeRange.TextFrame2.MarginTop = 0
    Selection.ShapeRange.TextFrame2.MarginBottom = 0
    Selection.ShapeRange.TextFrame2.VerticalAnchor = msoAnchorMiddle
    Selection.ShapeRange.TextFrame2.TextRange.ParagraphFormat.Alignment = _
        msoAlignCenter
    Selection.ShapeRange.TextFrame2.TextRange.ParagraphFormat.Alignment = _
        msoAlignCenter

    'fourth charts


    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.ChartType = xlDoughnut

    With ActiveChart.Parent
         .Height = 144
         .Width = 144
         .Top = 120
         .Left = 520
    End With

    ActiveChart.SetSourceData Source:=Sheets("Data").Range("Z4:AA9")
    ActiveChart.Legend.Select
    Selection.Delete

    ActiveChart.SeriesCollection(1).Select
    ActiveChart.ChartGroups(1).FirstSliceAngle = 270
    ActiveChart.PlotArea.Select
    ActiveChart.SeriesCollection(1).Select
    ActiveChart.SeriesCollection(1).Points(6).Select
    Selection.Format.Fill.Visible = msoFalse
    ActiveChart.SeriesCollection(1).Points(2).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(255, 0, 0)
        .Transparency = 0
        .Solid
    End With
    ActiveChart.SeriesCollection(1).Points(3).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(255, 192, 0)
        .Transparency = 0
        .Solid
    End With
    ActiveChart.SeriesCollection(1).Points(4).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(146, 208, 80)
        .Transparency = 0
        .Solid
    End With
    ActiveChart.SeriesCollection(1).Points(5).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(0, 176, 80)
        .Transparency = 0
        .Solid
    End With
    ActiveChart.ChartArea.Border.LineStyle = xlNone        

    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.ChartType = xlPie

    With ActiveChart.Parent
         .Height = 144
         .Width = 144
         .Top = 120
         .Left = 520
    End With

    ActiveChart.SetSourceData Source:=Sheets("Data").Range("AM4:AM6")
    ActiveChart.Legend.Select
    Selection.Delete
    ActiveChart.SeriesCollection(1).Select
    ActiveChart.SeriesCollection(1).Points(3).Select
    Selection.Format.Fill.Visible = msoFalse
    ActiveChart.SeriesCollection(1).Points(1).Select
    Selection.Format.Fill.Visible = msoFalse
    ActiveChart.SeriesCollection(1).Points(3).Select
    ActiveChart.SeriesCollection(1).Points(2).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.ObjectThemeColor = msoThemeColorText1
        .ForeColor.TintAndShade = 0
        .ForeColor.Brightness = 0
        .Transparency = 0
        .Solid
    End With
    ActiveChart.ChartGroups(1).FirstSliceAngle = 270
    ActiveChart.ChartArea.Select

    ActiveChart.ChartArea.Border.LineStyle = xlNone
    ActiveChart.ChartArea.Fill.Visible = False        

    ActiveChart.Shapes.AddShape(msoShapeOval, 58.25, 61.6250393701, 25.5, 25.5). _
        Select
    Selection.ShapeRange.IncrementLeft -3.75
    Selection.ShapeRange.IncrementTop -5.25
    Selection.ShapeRange.Fill.Visible = msoFalse      

    Selection.Characters.Text = Range("Data!AM9").Value

    With Selection.ShapeRange.TextFrame2.TextRange.Font.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(0, 0, 0)
        .Transparency = 0
        .Solid
    End With        

    Selection.ShapeRange.TextFrame2.MarginLeft = 0
    Selection.ShapeRange.TextFrame2.MarginRight = 0
    Selection.ShapeRange.TextFrame2.MarginTop = 0
    Selection.ShapeRange.TextFrame2.MarginBottom = 0
    Selection.ShapeRange.TextFrame2.VerticalAnchor = msoAnchorMiddle
    Selection.ShapeRange.TextFrame2.TextRange.ParagraphFormat.Alignment = _
        msoAlignCenter
    Selection.ShapeRange.TextFrame2.TextRange.ParagraphFormat.Alignment = _
        msoAlignCenter            

    ActiveSheet.Shapes.AddShape(msoShapeRoundedRectangle, 43.5, 122.25, 138, 116.25 _
        ).Select
    Selection.ShapeRange.Fill.Visible = msoFalse
    Selection.ShapeRange.TextFrame2.VerticalAnchor = msoAnchorBottom
    Selection.ShapeRange.TextFrame2.TextRange.ParagraphFormat.Alignment = _
        msoAlignCenter
    Selection.ShapeRange.TextFrame2.TextRange.Font.Bold = msoTrue
    Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = "English"
    With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 7). _
        ParagraphFormat
        .FirstLineIndent = 0
        .Alignment = msoAlignCenter
    End With
    With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 7).Font
        .Bold = msoTrue
        .NameComplexScript = "+mn-cs"
        .NameFarEast = "+mn-ea"
        .Fill.Visible = msoTrue
        .Fill.ForeColor.RGB = RGB(0, 0, 0)
        .Fill.Transparency = 0
        .Fill.Solid
        .Size = 16
        .Name = "+mn-lt"
    End With
    Selection.ShapeRange.TextFrame2.MarginBottom = 0    

    ActiveSheet.Shapes.AddShape(msoShapeRoundedRectangle, 203.5, 122.25, 138, 116.25 _
        ).Select
    Selection.ShapeRange.Fill.Visible = msoFalse
    Selection.ShapeRange.TextFrame2.VerticalAnchor = msoAnchorBottom
    Selection.ShapeRange.TextFrame2.TextRange.ParagraphFormat.Alignment = _
        msoAlignCenter
    Selection.ShapeRange.TextFrame2.TextRange.Font.Bold = msoTrue
    Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = "Science"
    With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 7). _
        ParagraphFormat
        .FirstLineIndent = 0
        .Alignment = msoAlignCenter
    End With
    With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 7).Font
        .Bold = msoTrue
        .NameComplexScript = "+mn-cs"
        .NameFarEast = "+mn-ea"
        .Fill.Visible = msoTrue
        .Fill.ForeColor.RGB = RGB(0, 0, 0)
        .Fill.Transparency = 0
        .Fill.Solid
        .Size = 16
        .Name = "+mn-lt"
    End With
    Selection.ShapeRange.TextFrame2.MarginBottom = 0

    ActiveSheet.Shapes.AddShape(msoShapeRoundedRectangle, 363.5, 122.25, 138, 116.25 _
        ).Select
    Selection.ShapeRange.Fill.Visible = msoFalse
    Selection.ShapeRange.TextFrame2.VerticalAnchor = msoAnchorBottom
    Selection.ShapeRange.TextFrame2.TextRange.ParagraphFormat.Alignment = _
        msoAlignCenter
    Selection.ShapeRange.TextFrame2.TextRange.Font.Bold = msoTrue
    Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = "Maths"
    With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 5). _
        ParagraphFormat
        .FirstLineIndent = 0
        .Alignment = msoAlignCenter
    End With
    With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 5).Font
        .Bold = msoTrue
        .NameComplexScript = "+mn-cs"
        .NameFarEast = "+mn-ea"
        .Fill.Visible = msoTrue
        .Fill.ForeColor.RGB = RGB(0, 0, 0)
        .Fill.Transparency = 0
        .Fill.Solid
        .Size = 16
        .Name = "+mn-lt"
    End With
    Selection.ShapeRange.TextFrame2.MarginBottom = 0

    ActiveSheet.Shapes.AddShape(msoShapeRoundedRectangle, 523.5, 122.25, 138, 116.25 _
        ).Select
    Selection.ShapeRange.Fill.Visible = msoFalse
    Selection.ShapeRange.TextFrame2.VerticalAnchor = msoAnchorBottom
    Selection.ShapeRange.TextFrame2.TextRange.ParagraphFormat.Alignment = _
        msoAlignCenter
    Selection.ShapeRange.TextFrame2.TextRange.Font.Bold = msoTrue
    Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = "Humanities"
    With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 10). _
        ParagraphFormat
        .FirstLineIndent = 0
        .Alignment = msoAlignCenter
    End With
    With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 10).Font
        .Bold = msoTrue
        .NameComplexScript = "+mn-cs"
        .NameFarEast = "+mn-ea"
        .Fill.Visible = msoTrue
        .Fill.ForeColor.RGB = RGB(0, 0, 0)
        .Fill.Transparency = 0
        .Fill.Solid
        .Size = 16
        .Name = "+mn-lt"
    End With
    Selection.ShapeRange.TextFrame2.MarginBottom = 0

    ActiveSheet.Shapes.AddShape(msoShapeRoundedRectangle, 43.5, 250, 138, 116.25 _
        ).Select
    Selection.ShapeRange.Fill.Visible = msoFalse
    With Selection.ShapeRange.TextFrame2.TextRange.Font.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(0, 0, 0)
        .Transparency = 0
        .Solid
    End With
    Selection.ShapeRange.TextFrame2.TextRange.Font.Size = 24
    Selection.ShapeRange.TextFrame2.TextRange.Font.Bold = msoTrue
    Selection.ShapeRange.TextFrame2.VerticalAnchor = msoAnchorMiddle
    Selection.ShapeRange.TextFrame2.TextRange.ParagraphFormat.Alignment = _
        msoAlignCenter
    Selection.Characters.Text = Range("Data!AC11").Value

ActiveSheet.Shapes.AddShape(msoShapeRoundedRectangle, 203.5, 250, 138, 116.25 _
        ).Select
    Selection.ShapeRange.Fill.Visible = msoFalse
    With Selection.ShapeRange.TextFrame2.TextRange.Font.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(0, 0, 0)
        .Transparency = 0
        .Solid
    End With
    Selection.ShapeRange.TextFrame2.TextRange.Font.Size = 24
    Selection.ShapeRange.TextFrame2.TextRange.Font.Bold = msoTrue
    Selection.ShapeRange.TextFrame2.VerticalAnchor = msoAnchorMiddle
    Selection.ShapeRange.TextFrame2.TextRange.ParagraphFormat.Alignment = _
        msoAlignCenter
    Selection.Characters.Text = Range("Data!AF11").Value

ActiveSheet.Shapes.AddShape(msoShapeRoundedRectangle, 363.5, 250, 138, 116.25 _
        ).Select
    Selection.ShapeRange.Fill.Visible = msoFalse
    With Selection.ShapeRange.TextFrame2.TextRange.Font.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(0, 0, 0)
        .Transparency = 0
        .Solid
    End With
    Selection.ShapeRange.TextFrame2.TextRange.Font.Size = 24
    Selection.ShapeRange.TextFrame2.TextRange.Font.Bold = msoTrue
    Selection.ShapeRange.TextFrame2.VerticalAnchor = msoAnchorMiddle
    Selection.ShapeRange.TextFrame2.TextRange.ParagraphFormat.Alignment = _
        msoAlignCenter
    Selection.Characters.Text = Range("Data!AI11").Value    

ActiveSheet.Shapes.AddShape(msoShapeRoundedRectangle, 523.5, 250, 138, 116.25 _
        ).Select
    Selection.ShapeRange.Fill.Visible = msoFalse
    With Selection.ShapeRange.TextFrame2.TextRange.Font.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(0, 0, 0)
        .Transparency = 0
        .Solid
    End With
    Selection.ShapeRange.TextFrame2.TextRange.Font.Size = 24
    Selection.ShapeRange.TextFrame2.TextRange.Font.Bold = msoTrue
    Selection.ShapeRange.TextFrame2.VerticalAnchor = msoAnchorMiddle
    Selection.ShapeRange.TextFrame2.TextRange.ParagraphFormat.Alignment = _
        msoAlignCenter
    Selection.Characters.Text = Range("Data!AL11").Value   


ActiveSheet.Shapes.AddChart.Select
    ActiveChart.ChartType = xlRadar
    ActiveChart.SetSourceData Source:=Sheets("Data").Range("AP4:AQ7")
    ActiveChart.Legend.Select
    Selection.Delete
    ActiveChart.Axes(xlValue).Select
    Selection.Delete        

    With ActiveChart.Parent
         .Height = 245
         .Width = 200
         .Top = 120
         .Left = 680
    End With   

    Range("C6").Activate

End Sub

0 个答案:

没有答案