excel - 从指定单元格向上计数行

标签 excel vba

我在 VBA 方面相当薄弱。
我试图在图片中找到表 1 和表 2 的行数。

Trying to find no. of rows count in table 1 and 2

我试图在下面的 VBA 代码中从 Cell A12 向上计数行(向后工作),

LastRow=sheet("Sheet1").Range("A12").end(xlUp).row

但这似乎不起作用。 Cells(Rows.Count, 1).End(xlUp).Row 将计算行数到 table2 ;因此不起作用。
您是否有更好的想法/代码来计算表 1 和表 2?
谢谢!

最佳答案

Sub FFF()
    Dim rng, cell
    Set cell = Cells(Rows.Count, 1).End(xlUp) '//Start cell
    Do
        Set rng = cell.CurrentRegion
        MsgBox "The count of cells in table " & rng.Address & " is: " & rng.Cells.Count
        Set cell = rng(1).End(xlUp)
    Loop Until cell.Row = 1
End Sub

关于excel - 从指定单元格向上计数行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59445317/

相关文章:

java - 通过 "Executable Jar"文件运行 selenium 测试时无法从 xls 获取测试数据

excel - 如何在 Excel VBA 中将整数设为 null?

excel - 将代码从 Excel 宏转换为 PowerShell

VBA:将类项添加到类内的集合中

VBA Worksheet_SelectionChange 不起作用

vba - Excel 函数(或 VBA)检查单元格中的相同值

angularjs - 使用Alasql可以用空字符串替换空列

excel - "Clicking"其他工作簿中的命令按钮

excel - 如何使 Excel 从 TFS 2010 工作项查询自动刷新

excel - 增加包含数字和文本 VBA 的单元格值