更具体来说,我无法弄清楚通用代码会计算从 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.CountPlease 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 SubThis 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.
更多推荐
存在数据的行数
发布评论