Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Count Number of Rows in a Workbook
Hello Everyone,
Can anyone tell me how to run a macro that will: * open a workbook * count the number of rows * write this number in the first workbook thanks! Dave |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Count Number of Rows in a Workbook
Dave,
Try something like the following. Change the workbook, worksheet, and range references in the lines marked with '<<<< to the appropriate values. Sub AAA() Dim SaveWB As Workbook Dim WB As Workbook Dim WS As Worksheet Dim Rng As Range Dim NumRows As Long Set SaveWB = ActiveWorkbook Set WB = Workbooks.Open("C:\Test\Book1.xls") '<<<< CHANGE Set WS = WB.Worksheets("Sheet1") '<<<< CHANGE With WS.UsedRange NumRows = .Cells(.Cells.Count).Row - .Cells(1, 1).Row + 1 End With WB.Close savechanges:=False SaveWB.Worksheets("Sheet1").Range("A1").Value = NumRows '<<<< CHANGE End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting www.cpearson.com (email on the web site) "Dave" wrote in message ... Hello Everyone, Can anyone tell me how to run a macro that will: * open a workbook * count the number of rows * write this number in the first workbook thanks! Dave |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
COUNT NUMBER OF ROWS | Excel Worksheet Functions | |||
Count how many Rows ago a particular number was hit | Excel Worksheet Functions | |||
Count number of rows, where non relevant rows are hidden | Excel Discussion (Misc queries) | |||
Count rows and insert number to count them. | Excel Discussion (Misc queries) | |||
Count the number of worksheets in a workbook | Excel Discussion (Misc queries) |