试试 Sub Drawing()
Application.ScreenUpdating = False
For i = 1 To [a65536].End(xlUp).Row
If Left(Cells(i, 1), 2) = "cs" Then
Charts.Add
With ActiveChart
.ChartType = xlXYScatterLines
.SetSourceData Source:=Cells(i + 1, 1).Resize(Cells(i, 2), 2), PlotBy _
:=xlColumns
.SeriesCollection(1).Name = Cells(i, 1)
.Location Where:=xlLocationAsObject, Name:="Sheet1"
End With
crt = ActiveChart.Name
crt = Mid$(crt, InStr(1, crt, "Chart"))
With ActiveSheet.Shapes(crt)
.Top = Cells(i, 4).Top
.Left = Cells(i, 4).Left
.Height = Cells(i, 2) * Cells(i, 2).Height
End With
End If
Next
Application.ScreenUpdating = True
MsgBox "Ready"
End Sub |