Attribute VB_Name = "LoopFilesInFolder" ' Loops through every .xlsx in a chosen folder and prints the file name + row count. Sub LoopFilesInFolder() Dim folderPath As String, file As String Dim wb As Workbook, n As Long With Application.FileDialog(msoFileDialogFolderPicker) If .Show <> -1 Then Exit Sub folderPath = .SelectedItems(1) & "\" End With file = Dir(folderPath & "*.xlsx") Do While file <> "" Set wb = Workbooks.Open(folderPath & file, ReadOnly:=True) Debug.Print file, wb.Sheets(1).UsedRange.Rows.Count wb.Close SaveChanges:=False n = n + 1 file = Dir Loop MsgBox "Processed " & n & " files. See the Immediate window (Ctrl+G).", vbInformation End Sub