2022年7月14日木曜日

vbaで最大行を求めるにはxldownよりもxlupを使うのが良さそうだ。これをVBA SNIPPETSにする。

Cells(1, 1).End(xlDown).Rowではなく、Cells(Rows.Count, 1).End(xlUp).Rowの方が良さそうだ。

'Snippets for VBA
'Get maxRow and maxClm
  Dim maxRow As Long
  maxRow = Cells(Rows.Count, 1).End(xlUp).Row 'the last Row of column A
  maxClm = Cells(1, Columns.Count).End(xlToLeft).Column 'max Column of row 1

0 件のコメント:

コメントを投稿