[英]Count rows and copy number
I have an excel workbook with multiple sheets with tables in the range from A to L . 我有一本Excel工作簿,其中有多个工作表,表的范围从A到L。 I want to count the rows and paste the result into a summary sheet.
我要计算行数并将结果粘贴到摘要表中。
For example: 例如:
Sheet2 has 3 rows. Sheet2有3行。 I want to copy the number of rows into sheet1 C3
我想将行数复制到sheet1 C3中
Sheet3 has 9 rows. Sheet3有9行。 I want to copy the number of rows into sheet1 C4
我想将行数复制到sheet1 C4中
Sheet4 has 5 rows. Sheet4有5行。 I want to copy the number of rows into sheet1 C5
我想将行数复制到sheet1 C5中
and so on through all my sheets. 等等,遍历我的所有工作表。 (I have over 3000 sheets)
(我有3000多张纸)
I am new to macro in excel so I would appreciete any help, thanks so much. 我是excel宏的新手,所以我将不胜感激,非常感谢。
No macro needed just us a formula: 没有宏只需要我们一个公式:
=COUNTA(Sheet2!A:A)
changing sheet2 to the approrpiate sheet for each cell in C3, C4, C5 =COUNTA(Sheet2!A:A)
将C2,C4,C5中每个单元格的sheet2更改为合适的表
Put simply...put 简单地说...放
=COUNTA(Sheet2!A:A)
in C3 C3中的
=COUNTA(Sheet2!A:A)
=COUNTA(Sheet3!A:A)
in C4 =COUNTA(Sheet3!A:A)
C4中的=COUNTA(Sheet3!A:A)
=COUNTA(Sheet4!A:A)
in C5 =COUNTA(Sheet4!A:A)
C5中的=COUNTA(Sheet4!A:A)
Assuming Column A in each sheet has a value when you want to count the row, otherwise use a different column! 假设要计算行数时,假设每张工作表中的A列都有一个值,否则请使用其他列! (changing A:A to B:B or something else)
(将A:A更改为B:B或其他)
If the names aren't sheet1 etc... you could.... 如果名称不是sheet1等,则可以...
Create this defined name: Formulas tab > Name Manager > New 创建此定义的名称:“公式”选项卡>“名称管理器”>“新建”
Then add this formula to B instead of the numbers 然后将此公式添加到B而不是数字
=INDEX(MID(SheetNames,FIND("]",SheetNames)+1,255),ROWS(A$1:A1))
Fill down and now you have the values to fill in your c3 and beyond 填写下来,现在您可以填入c3及以后的值
Hope this simple macro helps: 希望这个简单的宏可以帮助您:
Sub coutndisplay()
Dim count As Integer
' Create an object for sheet 1
Set sh1 = ThisWorkbook.Sheets(1)
' Get the number of sheets in the workbook
count = ThisWorkbook.Sheets.count
For i = 2 To count
' Populate the number of rows in sheet 1 starting from C3
' C3 populate the number of rows in sheet 2 and it goes on
sh1.Cells(i + 1, 3) = ThisWorkbook.Sheets(i).UsedRange.Rows.count
Next i
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.