可以简化些: Sub DrawChart() ' Keyboard Shortcut: Ctrl+d ' Dim myArea As Object Dim n As Integer Dim ch As ChartObject Dim ws As Worksheet Set ws = Worksheets("ppk") For Each ch In ws.ChartObjects If Not (Intersect(ws.Range("A8:H20"), ch.TopLeftCell) Is Nothing) Then ch.Delete Next ch n = Range("c61").Value If n > 79 Then MsgBox "you input a number bigger than 15,system will use the 15 as step" n = 79 End If Set ch = ws.ChartObjects.Add([A8].Left, [A8].Top, Range("A8:H20").Width, Range("A8:H20").Height) Set myArea = Worksheets("ppk").Range("K65").Resize(n, 1) With ch.Chart .ChartType = xlColumnClustered .SetSourceData Source:=myArea, PlotBy:=xlColumns .SeriesCollection(1).XValues = myArea.Offset(0, -1) .Location Where:=xlLocationAsObject, Name:="ppk" .HasLegend = False End With End Sub
[此贴子已经被作者于2007-5-29 13:08:11编辑过] |