another search question

Herman

New Member
Joined
Feb 28, 2002
Messages
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
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
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
 
Upvote 0
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
 
Upvote 0
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

Herman,

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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,213,511
Messages
6,114,054
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top