Excel VBA 行数计算

一、用连续区域,好处,其中某一行尾单元格为空值,不影响行数计算

Dim irow As Integer
irow = Range("a1").CurrentRegion.Rows.count

二、 取活动单元表的** **D列最后一个有值的行的行号,如果D行行尾刚好空值,表其他行不为空,行数是错误的

Dim irow As Integer
irow = Cells(Rows.Count, "d").End(xlUp).Row