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?

VBA学習備忘録_08_ある特定の行・特定の列の選択

0
Last updated at Posted at 2026-03-08

の続き


以下のマクロはいずれもある特定行を選択するマクロである(例として45行目を選択)

行ではなく列を取得する場合は、「Row」を「Column」に置き換える

Sub RowNumGet1()
  Range("A45").EntireRow.Select
End Sub
Range("45").EntireRow.Select

のようにRangeの引数は行番号のみ・列番号のみの場合はエラーになる

Sub RowNumGet2()
  Range("45:45").Select
End Sub
Sub RowNumGet3()
  Rows("45:45").Select
End Sub

本来 Rows("〇:△").Select は複数行を選択するもの

Sub RowNumGet3()
  Rows("45").Select
End Sub

Rowsの本来の引数は下のように数値とすべきであるが、ダブルクォーテーションがついていても、文字列型から数値型への暗黙の型変換が行われる

Sub RowNumGet3()
  Rows(45).Select
End Sub

主な参考資料

①この1冊で合格! 永井雅明のExcel VBA ベーシック テキスト&問題集

Amazonリンク

https://www.amazon.co.jp/%E3%81%93%E3%81%AE1%E5%86%8A%E3%81%A7%E5%90%88%E6%A0%BC-%E6%B0%B8%E4%BA%95%E9%9B%85%E6%98%8E%E3%81%AEExcel-VBA-%E3%83%99%E3%83%BC%E3%82%B7%E3%83%83%E3%82%AF-%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88/dp/4046071524?tag=googhydr-22&source=dsa&hvcampaign=books&gad_source=1

②Microsoft公式 Rowsプロパティ
https://learn.microsoft.com/ja-jp/office/vba/api/excel.range.rows

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?