count the rows in multiple file

freez

New Member
Joined
Jun 14, 2015
Messages
4
Hi
i search the forum but nothing found..
i have about 50 excel file in a folder in average of 30 Mb
i need to have number of rows in each file with file name in separated file
like this:

a.xls 51229
b.xls 49491
c.xls 44
.
.
.


what should i do?
macros can do this?
(also if i can have columns count it's seems better:) )
Thanks
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
You need to count number of rows in ALL sheets or only the first one?
 
Upvote 0
It'd be better if you'd upload an excerpt of your real data in one file. Without a file, I would advice to use UsedRange.Rows count, but this method is not that reliable.
 
Upvote 0
the problem is that i don't know VBA :)
the file is very simple excel with columns filed with numbers and strings
if it's nesscery to upload?
 
Upvote 0
I've sent you workbook with a button inside. The macro collecting data is simple:

Code:
Sub CollectData()

    Dim fso As Object, xlFile As Object
    Dim sFolder$
    Dim r&, j&

    With Application.FileDialog(msoFileDialogFolderPicker)
        .AllowMultiSelect = False
        .InitialFileName = ThisWorkbook.Path
        If .Show Then sFolder = .SelectedItems(1) Else Exit Sub
    End With
    Set fso = CreateObject("Scripting.FileSystemObject")
    For Each xlFile In fso.GetFolder(sFolder).Files
        With Workbooks.Open(xlFile.Path)
            With .Sheets(1)
                j = .Cells(.Rows.Count, 1).End(xlUp).Row
            End With
            .Close False
        End With
        r = r + 1
        Cells(r, 1).Value = xlFile.Name
        Cells(r, 2).Value = j
    Next

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,259
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top