Range.Copy メソッド (Excel)Range.Copy method (Excel)
範囲を、指定の範囲またはクリップボードにコピーします。Copies the range to the specified range or to the Clipboard.
注意
複数のプラットフォーム間で Office エクスペリエンスを拡張するソリューションを開発することに関心がありますか?Interested in developing solutions that extend the Office experience across multiple platforms? 新しい Office アドイン モデルを参照してください。Check out the new Office Add-ins model. Office アドインには、VSTO アドインおよびソリューションと比較して、小さな設置面積があります。 HTML5、JavaScript、CSS3、XML など、ほぼすべての web プログラミングテクノロジを使用して構築できます。Office Add-ins have a small footprint compared to VSTO Add-ins and solutions, and you can build them by using almost any web programming technology, such as HTML5, JavaScript, CSS3, and XML.
構文Syntax
式.コピー (コピー先)expression.Copy (Destination)
expression は Range オブジェクトを表す変数です。expression A variable that represents a Range object.
パラメーターParameters
名前Name | 必須 / オプションRequired/Optional | データ型Data type | 説明Description |
---|---|---|---|
DestinationDestination | 省略可能Optional | VariantVariant | コピー先のセル範囲。Specifies the new range to which the specified range will be copied. この引数を省略すると、クリップボードにコピーされます。If this argument is omitted, Microsoft Excel copies the range to the Clipboard. |
戻り値Return value
バリアント型Variant
例Example
次のコード例は、シート 1 のセル範囲 A1:D4 内の式をシート 2 のセル範囲 E5:H8 にコピーします。The following code example copies the formulas in cells A1:D4 on Sheet1 into cells E5:H8 on Sheet2.
Worksheets("Sheet1").Range("A1:D4").Copy _
destination:=Worksheets("Sheet2").Range("E5")
次のコード例は、シート 1 の各行の列 D に含まれる値を検査します。The following code example inspects the value in column D for each row on Sheet1. 列 D の値が A の場合、その行全体がシート A の空になっている次の行にコピーされます。If the value in column D equals A, the entire row is copied onto SheetA in the next empty row. 値が B の場合、行はシート B にコピーされます。If the value equals B, the row is copied onto SheetB.
Public Sub CopyRows()
Sheets("Sheet1").Select
' Find the last row of data
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
' Loop through each row
For x = 2 To FinalRow
' Decide if to copy based on column D
ThisValue = Cells(x, 4).Value
If ThisValue = "A" Then
Cells(x, 1).Resize(1, 33).Copy
Sheets("SheetA").Select
NextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
Cells(NextRow, 1).Select
ActiveSheet.Paste
Sheets("Sheet1").Select
ElseIf ThisValue = "B" Then
Cells(x, 1).Resize(1, 33).Copy
Sheets("SheetB").Select
NextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
Cells(NextRow, 1).Select
ActiveSheet.Paste
Sheets("Sheet1").Select
End If
Next x
End Sub
サポートとフィードバックSupport and feedback
Office VBA またはこの説明書に関するご質問やフィードバックがありますか?Have questions or feedback about Office VBA or this documentation? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.