计算另一个工作表中的行数 [英] Count the number of rows in another sheet
问题描述
我已经查看了建议的问题,以找到我的问题的答案。
最接近的问题叫做
计算不同Excel工作表中的行数
计算不同Excel表格中的行数
该问题的解决方案不适用于我正在尝试计算不同工作表范围内的行数,而不是活动工作表。
这是我的代码:
Sub verbflashcards()
Dim wordcount As Long
与Worksheets(Verbs)
wordcount = .Range(Cells(4,1),Cells(4,1).End(xlDown))。Rows.Count
结束
MsgBox(wordcount)
End Sub
我有一个名为动词的工作表,它是工作簿中的第二个工作表。我试过:
用动词
With Sheet2
带表格(动词)
with Sheets(Sheet2)
他们似乎都没有工作。
查看这个,希望这将有助于您:
Sub verbflashcards()
Dim wordcount As Long
wordcount = ActiveWorkbook.Worksheets(Verbs)。Range(A4,Worksheets (动词)范围(A4)。结束(xlDown))Rows.Count
MsgBox(wordcount)
End Sub
其中, D1 是可以从中获取行数的列。
方法2:
Sub verbflashcards()
Dim wordcount As Long
With Sheets(Verbs)
wordcount = .Range(A& .Rows.Count).End(xlUp).Row
结束
MsgBox(wordcount)
End Sub
注意:你的问题有很多答案。检查这个SO链接:如何在Excel表格中找到包含宏的最后一行?
I have looked at the suggested questions to find the answer to my problem. The closest question is called: Count number of rows in a different Excel Sheet Count number of rows in a different Excel Sheet
The solution to that problem does not work for me.
I am trying to count the number of rows in a range in a different worksheet than the active worksheet. Here is my code:
Sub verbflashcards()
Dim wordcount As Long
With Worksheets("Verbs")
wordcount = .Range(Cells(4, 1), Cells(4, 1).End(xlDown)).Rows.Count
End With
MsgBox (wordcount)
End Sub
I have a worksheet called Verbs and it is the second worksheet in the workbook. I have tried:
With Verbs
With Sheet2
With Sheets("Verbs")
With Sheets("Sheet2")
None of them seem to work.
Check this and hope this will help you:
Sub verbflashcards()
Dim wordcount As Long
wordcount = ActiveWorkbook.Worksheets("Verbs").Range("A4", Worksheets("Verbs").Range("A4").End(xlDown)).Rows.Count
MsgBox (wordcount)
End Sub
Where, D1 is the column from which you can get row count.
Method 2:
Sub verbflashcards()
Dim wordcount As Long
With Sheets("Verbs")
wordcount = .Range("A" & .Rows.Count).End(xlUp).Row
End With
MsgBox (wordcount)
End Sub
Note: There are lots of answers to your questions. Check this SO link: How can I find last row that contains data in the Excel sheet with a macro?
这篇关于计算另一个工作表中的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!