存在数据的行数 [英] Row count where data exists
问题描述
更具体来说,我无法弄清楚通用代码会计算从
A1 - A100或A1- A300。
现在我正在尝试使用这样的东西,但它不起作用。
i = ActiveWorkbook.Worksheets(Sheet1)。Range(A2,Range(A2)。End(xlDown ))。Rows.Count
请帮助!
谢谢
如果你需要VBA,你可以这样做一些快速的事情:
Sub Test()
With ActiveSheet
lastRow = .Cells(.Rows.Count,A)。End(xlUp)。行
MsgBox lastRow
结束
结束子
这将打印最后一行的数据,其中包含数据。显然,如果您将其用于其他目的,则不需要MsgBox,但lastRow将成为该值。
I am new to learning VBA and was wondering if someone could help me with the code I need to count the total number of rows that I have with data in them. I want to be able to use this on multiple sheets with different amounts of data rows.
More specifically I cannot figure out generic code that will count the number of rows from A1 - A100 or A1- A300.
Right now I am trying to use something like this, but it does not work.
i = ActiveWorkbook.Worksheets("Sheet1").Range("A2 , Range("A2").End(xlDown)).Rows.Count
Please help!
Thanks
If you need VBA, you could do something quick like this:
Sub Test()
With ActiveSheet
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
MsgBox lastRow
End With
End Sub
This will print the number of the last row with data in it. Obviously don't need MsgBox in there if you're using it for some other purpose, but lastRow will become that value nonetheless.
这篇关于存在数据的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!