[英]How to get the number of rows in column A starting from a certain cell in excel
I would like to get the number of non-empty rows in Column A starting from A3 for example. 我想从A3开始获取A列中非空行的数量。 How do i do it?
我该怎么做?
What I have tried: 我试过的
Dim row as integer
row = Sheets("Part2").Cells(Rows.Count, 1).End(xlUp).row
But it calculates all the rows in columnA. 但是它会计算columnA中的所有行。 Want it to start it from A3.
希望它从A3启动。
Need some guidance. 需要一些指导。
For counting non empty cells starting from A3
use this one: 要计算从
A3
开始的非空单元格,请使用以下一项:
Dim cntRows As Long
With Sheets("Part2")
cntRows = WorksheetFunction.CountA(.Range("A:A")) - WorksheetFunction.CountA(.Range("A1:A2"))
End With
also note, that I'm using Long
type for cntRows
(since max value of Integer
is only 32768
) 还要注意,我对
cntRows
使用Long
类型(因为Integer
最大值仅为32768
)
Range("a3:a" & Rows.Count).SpecialCells(xlCellTypeConstants).Count
我首先使用Range("a3:a" & Rows.Count).SpecialCells(xlCellTypeBlanks).Count
尝试了另一个公式Range("a3:a" & Rows.Count).SpecialCells(xlCellTypeBlanks).Count
非常确定这是最佳路径,但奇怪的是这给了我一个错误...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.