Hello,
I am really hoping someone can help me with this. I have VBA code to count the numbers of files in folders but I also need to count the number of files in sub folders too which the total will be displayed in cells in the excel spreadsheet. This is the code I have for counting in folders:
Private Sub countBatches()
Dim FolderPath As String, path As String, count As Integer, dayid As String
dayid = Range("B1").Value
FolderPath = "C:\Users\Lisap\OneDrive\Desktop\Orders\" & dayid & "\Batches"
path = FolderPath & "\*"
Filename = Dir(path)
Do While Filename <> ""
count = count + 1
Filename = Dir()
Loop
Range("B2").Value = count
End Sub
Please can anyone help with this? I would be most grateful!
I am really hoping someone can help me with this. I have VBA code to count the numbers of files in folders but I also need to count the number of files in sub folders too which the total will be displayed in cells in the excel spreadsheet. This is the code I have for counting in folders:
Private Sub countBatches()
Dim FolderPath As String, path As String, count As Integer, dayid As String
dayid = Range("B1").Value
FolderPath = "C:\Users\Lisap\OneDrive\Desktop\Orders\" & dayid & "\Batches"
path = FolderPath & "\*"
Filename = Dir(path)
Do While Filename <> ""
count = count + 1
Filename = Dir()
Loop
Range("B2").Value = count
End Sub
Please can anyone help with this? I would be most grateful!