gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 20:51:22 26 4
gpt4 key购买 nike

我在 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com