简体   繁体   English

如何从Excel中的某个单元格开始获取A列中的行数

[英]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.

相关问题 当单元格/列包含某些文本时,如何从Excel数据集中提取所有行 - How to extract all rows from excel data set when cell/column contains certain text 如何将数组复制到从某个单元格开始的列的每个单元格,而不是复制到行的每个单元格? - How can I copy an array to each cell of a column starting from a certain cell, instead of to each cell of a row? VBA:删除从某个单元格开始的整数行数 - VBA: Delete integer number of rows starting at a certain cell VBA编码:如何将特定的列从标题向下复制到一定数量的行(每个excel文件都更改)到excel中的新表? - VBA coding: How to copy a specific column from header down till a certain number of rows (change for each excel file) to new sheet in excel? 如何计算 excel vba 中特定单元格数据的行数 - how to count the number of rows with data from a specific cell in excel vba Excel VBA。 如何选择某个单元格,然后向下偏移一个可变数字或行,然后打印该选择 - Excel VBA. How to select a certain cell, then offset a variable number or rows down, and then print that selection 在Excel中按单元格值获取列号 - Get column number by cell value in Excel 如何从单元格读取十进制数字并复制具有该单元格编号的所有行-EXCEL - How to read decimal number from cell and copy all rows that have that cell number - EXCEL 按行 NUMBER 和列 LETTER 获取 Excel 单元格 - Get Excel Cell by row NUMBER and column LETTER 从相同的单元格值VBA开始在Excel中添加多行 - Add multiple rows in Excel starting from same cell value VBA
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM