![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Feb 2002
Posts: 28
|
I have a directory with approx 800 xls files
i want to look if a xls file has a certain number in it.for example i want to search for number 6, when it is found in different files(for example in 300 files) i want a list in a new workbook in which workbook they stand, is this possible without opening each file . Greetings, Herman |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 2,908
|
Hello Herman,
You can experiment with this code to get what you want. It currently searches a specified folder and returns Excel workbooks containing a 6. HTH, Dan Code:
Sub ListFiles()
Dim lngLoop As Long
With Application.FileSearch
.NewSearch
.LookIn = "C:tempyour files"
.SearchSubFolders = True
.TextOrProperty = "6"
.FileType = msoFileTypeExcelWorkbooks
If .Execute > 0 Then
For lngLoop = 1 To .FoundFiles.Count
Cells(lngLoop, 1) = .FoundFiles(lngLoop)
Next
End If
End With
End Sub
[ This Message was edited by: dk on 2002-05-08 04:55 ] |
|
|
|
|
|
#3 |
|
New Member
Join Date: Feb 2002
Posts: 28
|
it isn't working, to be sure i want to look for a value 6 in the workbook(cel value0 the value 6 is not in the name of the xls file but has to be searched in the content of a workbook
greetings herman |
|
|
|
|
|
#4 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 2,908
|
Quote:
The code searches WITHIN the workbook for any cell containing a 6. If A1 contains 6 then this macro will return the filename. If it contains 66 then it won't. Did you run the code? What results did you get and what did you expect to get? Regards, Dan |
|
|
|
|
|
|
#5 |
|
New Member
Join Date: Feb 2002
Posts: 28
|
The code didn't find anything, i looked at it again and noticed that there is a line that says
.FileType = msoFileTypeExcelWorkbooks this can be the problem, the files i have are not real xls files but tab delimited files with the extension .plo is there a way to tell the macro that the filetype is .plo |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|