sarvadeshavyapta
New Member
- Joined
- Jul 31, 2015
- Messages
- 30
Is it possible to fetch the Folder property -"Contains" instead of looping through each file in VBA.I'm using following code to count the no. of files in folder.But curious to know.
Code:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; white-space: inherit;">[COLOR=#101094]Sub[/COLOR][COLOR=#303336] sample[/COLOR][COLOR=#303336]()[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#000000]Dim FolderPath AsString, path AsString, count AsInteger
FolderPath ="C:\Documents and Settings\"
path = FolderPath &"\*.xls"
Filename = Dir(path)
DoWhile Filename <>""
count = count +1
Filename = Dir()
Loop
Range("Q8").Value = count
MsgBox count & " : files found in folder"
End Sub[/COLOR]</code>