Jagdev Singh
Active Member
Hi Experts
I am trying to pull number of rows and columns for a folder. I am succeeded with pulling the name, but not able to pull the count of rows and numbers from the sheets.
Here is my current code.
Please let me know how to amend the code to pull the required data from the list of files.
Regards,
JD
I am trying to pull number of rows and columns for a folder. I am succeeded with pulling the name, but not able to pull the count of rows and numbers from the sheets.
Here is my current code.
Code:
Sub Example1()
Dim objFSO As Object
Dim objFolder As Object
Dim i As Integer
Dim rn As Range
Dim k As Long
Dim k1 As Long
'Create an instance of the FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get the folder object
Set objFolder = objFSO.GetFolder(ActiveWorkbook.Sheets(2).Range("E8").Value)
i = 1
'loops through each file in the directory and prints their names and path
For Each Sheet In objFolder.Files
'print file name
Cells(i + 1, 1) = Sheet.Name
' Set rn = Worksheets("Sheet1").UsedRange.Rows.Count
k = rn.Rows.Count + rn.Row - 1
'print file path
Cells(i + 1, 2) = k
k1 = rn.Columns.Count + rn.Column - 2
Cells(i + 1, 3) = k1
i = i + 1
Next Sheet
End Sub
Regards,
JD