B
broogle
This code below will count the total of files in c:\myfiles\
Is there a way to change the folder as dynamic, so user is free to
chose the folder she/he wants.
What I want is, when the code is running the pop up box will be shown
and user can browser to find the folder and when OK button is pressed
the code will count the files in that folde.
Thank and appreciate your help.
Private Sub countfiles()
Set fs = Application.FileSearch
With fs
.LookIn = "C:\Myfiles\"
.SearchSubFolders = False
.Filename = "*.xls"
If .Execute() > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
Range("A" & i) = .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With
End Sub
Is there a way to change the folder as dynamic, so user is free to
chose the folder she/he wants.
What I want is, when the code is running the pop up box will be shown
and user can browser to find the folder and when OK button is pressed
the code will count the files in that folde.
Thank and appreciate your help.
Private Sub countfiles()
Set fs = Application.FileSearch
With fs
.LookIn = "C:\Myfiles\"
.SearchSubFolders = False
.Filename = "*.xls"
If .Execute() > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
Range("A" & i) = .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With
End Sub