0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Excel VBAのRangeプロパティのパラメータの指定について

Last updated at Posted at 2017-01-13

しばらくExcelマクロを作成する機会がなかった為、すっかり忘れてしまった。。
今回また、エクセルVBAを使う機会が来たので、あらためて学ぼうと思う。

はじめに

 基本はセルの操作ということで
 1行のある範囲をCopyして他の行にPasteする。
 
 使用するExcel
  Excel 2010

1行のある範囲をコピーする

  A1からE1の範囲コピーをする。
  Range("A1:E1").Copy
  これは無事終了。

コピーした内容をある指定したセルにペーストする

  A2のセルにペーストする。(A2−E2に貼り付ける)
  1. Range("A2").PasteSpecial Paste:=xlPasteAll
  2. Range(Cells(2,1)).PasteSpecial Paste:=xlPasteAll
  3. Range(Cells(2,1),Cells(2,1)).PasteSpecial Paste:=xlPasteAll
  4. Cells(2,1).PasteSpecial Paste:=xlPasteAll
  1,2,3,4は正常。
   2だけエラーが発生した。

MSDNによると

**構文
式.Range(Cell1, Cell2)
...
Cell1 必須
Cell2 省略可能

https://msdn.microsoft.com/ja-jp/library/office/ff836512.aspx より引用)

となっていたがCellsの指定では省略できないようだ。※1

※1 Excel 2016でも同じ結果となった。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?