如何从excel中的某个单元格开始获取列A中的行数
我想从例如A3开始,获得列A中非空行的数量。 我该怎么做?
我曾经尝试过:
Dim row as integer row = Sheets("Part2").Cells(Rows.Count, 1).End(xlUp).row
但它会计算columnA中的所有行。 要从A3开始。
需要一些指导。
对于从A3
开始的非空单元计数,使用这个:
Dim cntRows As Long With Sheets("Part2") cntRows = WorksheetFunction.CountA(.Range("A:A")) - WorksheetFunction.CountA(.Range("A1:A2")) End With
还要注意,我正在使用Long
types的cntRows
(因为Integer
最大值只有32768
)
Range("a3:a" & Rows.Count).SpecialCells(xlCellTypeConstants).Count
我试着使用Range("a3:a" & Rows.Count).SpecialCells(xlCellTypeBlanks).Count
第一个另外的公式是相当肯定这是最好的path,但奇怪,给了我一个错误…