I have obtained the filename and corresponding folder in column a and b.
How Can I count the number of files in each folder and subfolder?
these are the references:
count files in specific folder and display the number into 1 cel
I have done the following so far
Private Sub SelectFolder_Click()
Call GetAllFolders(x, strPath, objFso, intCountRows)
Call count
End Sub
The following is the counting part
Sub count()
Dim FolderPath As String, path As String, count As Integer
Dim Filename As String
Dim strPath As String
FolderPath = "D:\Users\Desktop\test"
Filename = Dir("")
Do While Filename <> ""
count = count + 1
Filename = Dir()
Loop
Range("C3").Value = count
'MsgBox count & " : files found in folder"
End Sub
How Can I count the number of files in each folder and subfolder? Thanks
GetFileCount will count all the files in a directory and the directory's sub-directories.
Range("C3").Value = getFileCount("D:\Users\Desktop\test")