1
多くのスプレッドシートのデータを1つのシートにコピーしようとしています。私は範囲A:Lからコピーしており、サマリーシートのA:Lからデータを貼り付けると、問題なく動作します。列B:Mにデータを貼り付けようとしていますが、これは1004エラーが発生したときです。私はDomenicからWith DestSh.Cells(Last + 1, "A")
Excelエラー1004:領域とペースト領域が同じサイズではありません
With DestSh.Cells(Last + 1, "B")
から
' Loop through all worksheets and copy the data to the
' summary worksheet.
For Each sh In ActiveWorkbook.Worksheets
If sh.Name <> DestSh.Name And sh.Name <> "Pivot Table" And sh.Name <> "Combined" Then
' Find the last row with data on the summary
' and source worksheets.
Last = LastRow(DestSh)
shLast = FindLastRow(sh)
' If source worksheet is not empty and if the last
' row >= StartRow, copy the range.
If shLast > 0 And shLast >= StartRow Then
'Set the range that you want to copy
Set CopyRng = sh.Range(sh.Rows(StartRow), sh.Rows(shLast))
StartRow = 2
' Test to see whether there are enough rows in the summary
' worksheet to copy all the data.
If Last + CopyRng.Rows.Count > DestSh.Rows.Count Then
MsgBox "There are not enough rows in the " & _
"summary worksheet to place the data."
GoTo ExitTheSub
End If
' This statement copies values and formats.
CopyRng.Copy
With DestSh.Cells(Last + 1, "A")
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With
End If
End If
Next
「CopyRng」の*アドレス*とは何ですか? –
Doeはワークシートのいずれか、特にコピーされた(または宛先)の範囲にマージされたセルを含んでいますか? –
ちょうど興味深い - あなたは 'With DestSh.Cells(Last + 1,2)'を使ってエラーを受け取りますか?また、 'Last'は' Long'か 'Integer'ですか? – BruceWayne