Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: another search question

  1. #1
    New Member
    Join Date
    Feb 2002
    Posts
    28
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    2,940
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    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. #3
    New Member
    Join Date
    Feb 2002
    Posts
    28
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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. #4
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    2,940
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    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

  5. #5
    New Member
    Join Date
    Feb 2002
    Posts
    28
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •