montecarlo2079
Board Regular
- Joined
- Feb 9, 2011
- Messages
- 207
I want to be able to use text in a certain cell or input box be used to search through a folder and have every file name returned that the text is found in.
for example I want to search for the name "Smith" in a specified folder, and have vba return each file name that the word "smith" appears in
I found thise code, but for some reason its not working at all. in excel 2007
any ideas?
Sub FindText()Dim i As Integer'Search criteriaWith Application.FileSearch .LookIn = "c:\my documents\logs" 'path to look in .FileType = msoFileTypeAllFiles .SearchSubFolders = False .TextOrProperty = "*Find*" 'Word to find in this line .Execute 'start search'This loop will bring up a message box with the name of'each file that meets the search criteria For i = 1 To .FoundFiles.Count MsgBox .FoundFiles(i) Next iEnd WithEnd Sub</PRE>
for example I want to search for the name "Smith" in a specified folder, and have vba return each file name that the word "smith" appears in
I found thise code, but for some reason its not working at all. in excel 2007
any ideas?
Sub FindText()Dim i As Integer'Search criteriaWith Application.FileSearch .LookIn = "c:\my documents\logs" 'path to look in .FileType = msoFileTypeAllFiles .SearchSubFolders = False .TextOrProperty = "*Find*" 'Word to find in this line .Execute 'start search'This loop will bring up a message box with the name of'each file that meets the search criteria For i = 1 To .FoundFiles.Count MsgBox .FoundFiles(i) Next iEnd WithEnd Sub</PRE>