learning vba
New Member
- Joined
- Nov 20, 2016
- Messages
- 8
Hi guys,
I have a list of folder path in cust_folder sheet ( about 20 folder path in range A4: A24) i want the below code to loop through each cell in the range A4:A24 and list the count of excel files in Rage B4:B24)
Is there a way to use this code to work like that?
Thank you in advance
Sub sample()
Dim FolderPath As Range, path As String, count As Integer
FolderPath = Range("A4:A10")
' "E:\cust_log\2010\10"
For Each FolderPath In i
path = FolderPath & "\*.docx"
Filename = Dir(path)
Do While Filename <> ""
count = count + 1
Filename = Dir()
Loop
Range("QB" & i).Value = count
'MsgBox count & " : files found in folder"
Next FolderPath
End Sub
I have a list of folder path in cust_folder sheet ( about 20 folder path in range A4: A24) i want the below code to loop through each cell in the range A4:A24 and list the count of excel files in Rage B4:B24)
Is there a way to use this code to work like that?
Thank you in advance
Sub sample()
Dim FolderPath As Range, path As String, count As Integer
FolderPath = Range("A4:A10")
' "E:\cust_log\2010\10"
For Each FolderPath In i
path = FolderPath & "\*.docx"
Filename = Dir(path)
Do While Filename <> ""
count = count + 1
Filename = Dir()
Loop
Range("QB" & i).Value = count
'MsgBox count & " : files found in folder"
Next FolderPath
End Sub