Results 1 to 11 of 11

Include/Exclude Specific Instring Characters From A Querry Search

Threaded View

  1. #1
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Austin
    Posts
    660

    Include/Exclude Specific Instring Characters From A Querry Search

    Hi group,

    I have a querry- file search application macro which searches all directories and subdirectories found within the provided string path and brings in specific data from spreadsheets in those directories. I would like to have the ability to exclude some of the subdirectories which are currently being querried.

    I'm wondering if it is possible to add additional code that will allow me to either include or exclude specific directories being querried.

    Here's an excerpt of the code:
     Set fs = Application.FileSearch
      With fs
        .LookIn = Lookinpath
        .SearchSubFolders = True
        .FileName = "*bom*.xls"
        If .Execute() > 0 Then
          For i = 1 To .FoundFiles.Count
            If InStr(1, .FoundFiles(i), "COMPLETED") > 0 Then 'this is the test for completed files
              Application.StatusBar = "Actioning Completed " & i & " of " & .FoundFiles.Count & " Foundfiles"
              Workbooks.Open FileName:=.FoundFiles(i), UpdateLinks:=False
              Set sf = FSO.getFolder(ActiveWorkbook.Path)
    'do a test to see if the sheet to use is MASTER or only sheet in file
              If ActiveWorkbook.Sheets.Count = 1 Then 'action the only sheet
                startrow = Range("A:A").Find(what:="NUMBER").Row + 1
                For j = startrow To Cells(Rows.Count, 1).End(xlUp).Row
              
                  If Not IsEmpty(Cells(j, 1)) Then
                    outrow = OutPL.Cells.Rows.Count, 1).End(xlUp).Offset(1, 0).Row
                    OutPL.Cells(outrow, 1).Value = Cells(j, 1).Value
                    OutPL.Cells(outrow, 2).Resize(1, 3).Value = .FoundFiles(i)
    Since the directory names are part of the string path, would it be possible to add something like the following to the code?

     OutPL.Cells(outrow, 2).Resize(1, 3).Value = .FoundFiles(i) - InStr(1, .FoundFiles(i), "\TMP\")
    or

      If InStr(1, .FoundFiles(i), "\TMP\") > 0  Then Do Nothing
     Else
    'Then Do the following

    Any help is appreciated.

    Thanks,

    BDB
    Last edited by bdb1974; 01-05-2010 at 03:43 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1