|
▼あおこ さん:
>実行時エラー1004「WorksheetクラスのPasteメソッドが失敗しました」が出る
DoEventsの回数を増やしてください
Sub test2()
Dim cho As ChartObject
Dim d As Double
Dim k As Long
Dim r As Range
On Error Resume Next
Sheet2.ChartObjects.Delete
On Error GoTo 0
Set cho = Sheet1.ChartObjects(1).Duplicate.Parent
With Sheet2.Range("A1:A15")
cho.Height = .Height
d = .Rows.Count + 2
End With
cho.Width = Sheet2.Range("K1:S1").Width
'
Do
Set r = Sheet2.Range("A1:B6")
cho.Copy
DoEvents
DoEvents
DoEvents
Sheet2.Paste Sheet2.Range("k17").Offset(k * d)
With Sheet2.ChartObjects(k + 1).Chart
.SetSourceData Source:=r
.ChartTitle.Text = r(1).Value
End With
k = k + 1
Loop Until k > 5
cho.Delete
End Sub
|
|