2
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 3 years have passed since last update.

エクセルVBAにて最終行の次の行にコピーする方法(備忘録)

Posted at

エクセルVBAやpythonなどのプログラミング初心者の備忘録として以下の内容をまとめていきます。

業務で処理が必要になった「VBAで最終行をコピー&最終行の次の行に貼り付ける操作」。

ほぼほぼ参考サイト様の中身のままですが・・


Sub VBAのタイトルをここに記入()

最終行 = Cells(Rows.Count, “A”).End(xlUp).Row
最終行の次の行 = Cells(Rows.Count, “A”).End(xlUp).Row + 1

Range(“A” & 最終行).Copy
Range(“A” & 最終行の次の行).PasteSpecial

End Sub

最初の2行で最終行と最終行の次のセル番号を取得。

続いてそのセル番号の中身をコピーし、
最終行の次の行へ貼り付け。

1文ずつ丁寧に見ていくのがプログラミング初心者には
重要のようですね。

別シートを挟んで最終行→最終行の次の行にコピペは以下のよう。


Sub 別シートの最終行コピー後に最終行の次の行に貼り付け()

Sheets(“Sheet2”).Select
last = Cells(Rows.Count, “A”).End(xlUp).Row
Range(“A” & last).Copy
Sheets(“Sheet1”).Select
tugi = Cells(Rows.Count, “A”).End(xlUp).Row + 1
Range(“A” & tugi).PasteSpecial

End Sub

何度も書いてみて覚えなきゃですね・・

2
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
2
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?