Is there a way that I can list how many files are in each folder that is imported to my spread sheet? Can this be done to include folder size? I am new to VBA programming and trying to learn fast.
Thank you
Is there a way that I can list how many files are in each folder that is imported to my spread sheet? Can this be done to include folder size? I am new to VBA programming and trying to learn fast.
Thank you
Here is some VBA that allows you to pick a folder and then tells you how many files it contains:
![]()
Sub FileCounter() s = GetFolder & "/*.*" Filename = Dir(s) Do Until Filename = "" i = i + 1 Filename = Dir() Loop MsgBox i End Sub Function GetFolder() As String Dim fldr As FileDialog Dim sItem As String Set fldr = Application.FileDialog(msoFileDialogFolderPicker) With fldr .Title = "Select a Folder" .AllowMultiSelect = False .InitialFileName = Application.DefaultFilePath If .Show <> -1 Then GoTo NextCode sItem = .SelectedItems(1) End With NextCode: GetFolder = sItem Set fldr = Nothing End Function
Gary's Student
Is there a way to get it to print the folder name and the count number into a couple cells?
Ok cool working better. Is there a way to have it do this function with a main folder then check all of the sub folders?
How about:
![]()
Sub FileCounter() s = GetFolder & "/*.*" Filename = Dir(s) Do Until Filename = "" i = i + 1 Filename = Dir() Loop Range("A1").Value = s Range("B1").Value = i End Sub
ok thank you very much i added rep to you
It might be possible using the FileSystem Object. I suggest you open a new thread and mention what we have accomplished so far.
Thank you for the feedback!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks