「Excel VBA 最後のセルを取得」の版間の差分
ナビゲーションに移動
検索に移動
(ページの作成:「==Excel VBA 最後のセルを取得する== [Excel VBA] ===Excel ワークシート上の最終セルに移動する=== *Ctrl + End で最後のセルに移動す…」) |
|||
| 1行目: | 1行目: | ||
==Excel VBA 最後のセルを取得する== | ==Excel VBA 最後のセルを取得する== | ||
| − | [Excel VBA] | + | [[Excel VBA]] |
===Excel ワークシート上の最終セルに移動する=== | ===Excel ワークシート上の最終セルに移動する=== | ||
2020年2月15日 (土) 08:02時点における版
目次
Excel VBA 最後のセルを取得する
Excel ワークシート上の最終セルに移動する
- Ctrl + End で最後のセルに移動する
- 一旦Endキーを押して、Homeキーを押す
Excel ワークシート上の最終セルをVBAから取得する
シート全体
'A1から、Ctrl + End で取得できるセル
Dim sheet As Worksheet
Dim endCel As Range
Set sheet = ActiveSheet
Set endCel = sheet.Range("A1").SpecialCells(xlLastCell)
Debug.Print endCel.Row & "," & endCel.Column
列ごと
'1列目の最下行からCtrl + ↑ で取得できる行 Dim targetCol as Integer targetCol = 1 Set sheet = ActiveSheet sheet.Cells(Rows.Count,targetCol).End(xlUp).Row
データを削除しても、最終セル位置が元に戻らない場合
- 一旦、上書き保存を行う。
© 2006 矢木浩人