Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem in recursive file find in Excel 2007 VBA

Status
Not open for further replies.

phudgens

Technical User
Jul 8, 2004
117
US
I'm using the following code as part of a recursive subroutine to find files in all subfolders of a user specified intital folder.

Code:
    Set f = fs.GetFolder(FolderSpec)
    Set fc = f.SubFolders
    For Each F1 In fc
        'ChkFldr = FolderSpec & "\" & F1.Name
        'For i = 1 To iIgnoreFldrCnt
        '    If ChkFldr = IgnoreFldrs(i) Then
        '        MsgBox "Match found"
        '        GoTo NextF1
        '    End If
        'Next i
        If Trim(LCase(F1.Name)) = "fmi" Then GoTo NextF1
        If Trim(LCase(F1.Name)) = "offsetwelldata" Then GoTo NextF1
        If Trim(LCase(F1.Name)) = "petrel" Then GoTo NextF1
        Call ShowFolderInfo(FolderSpec & "\" & F1.Name, FileWks, IgnoreFldrs, iIgnoreFldrCnt)
NextF1:
    Next F1

As shown, the code works fine. If I uncomment the commented lines and comment the 3 If statements, however, it no longer works, that is, the program does not skip the specified folders even though matches are being found. Does anyone see any problems in this code. Thanks,
Paul Hudgens
Denver
 


Have you stepped thru the code and OBSERVED the VALUES of your variables as they are compared?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 

Could you add this blue line:
Code:
For i = 1 To iIgnoreFldrCnt[blue]
    Debug.Print "*" & ChkFldr & "* - *" & IgnoreFldrs(i) & "*"
[/blue]    If ChkFldr = IgnoreFldrs(i) Then
        MsgBox "Match found"
        GoTo NextF1
    End If
Next i
Paste it here and tell us where it SHOULD work, but it DOES NOT?

Have fun.

---- Andy
 
Here you go. The two strings (folders) I'm trying to match are:
R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData &
R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI

The program is finding matches for both, but not skipping them when it does, as it does do when using the 3 IF statements.


*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-
09D\CompletionData_DFITS* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\CompletionData_DFITS* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Corpscon* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Corpscon* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\DailyDrillingReport* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\DailyDrillingReport* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\Field* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\Field* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\Petrophysics* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\Petrophysics* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\SonicScanner* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\SonicScanner* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Maps* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Maps* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Misc* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Misc* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Mudlog* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Mudlog* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OFFSET_XPT* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OFFSET_XPT* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct10_2011_Petrel2009* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct10_2011_Petrel2009* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct10_2011_Petrel2009\Noble_Oct10_2011_Petrel2009.ptd* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct10_2011_Petrel2009\Noble_Oct10_2011_Petrel2009.ptd* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct10_2011_Petrel2009\Noble_Oct10_2011_Petrel2009.ptd\Ocean* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct10_2011_Petrel2009\Noble_Oct10_2011_Petrel2009.ptd\Ocean* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct10_2011_Petrel2009\Noble_Oct10_2011_Petrel2009.ptd\OceanExtensionData* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct10_2011_Petrel2009\Noble_Oct10_2011_Petrel2009.ptd\OceanExtensionData* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct10_2011_Petrel2009\Noble_Oct10_2011_Petrel2009.stf.dat* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct10_2011_Petrel2009\Noble_Oct10_2011_Petrel2009.stf.dat* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct17_2011_petrel2009* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct17_2011_petrel2009* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct17_2011_petrel2009\Noble_Oct17_2011_petrel2009_sav.ptd* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct17_2011_petrel2009\Noble_Oct17_2011_petrel2009_sav.ptd* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct17_2011_petrel2009\Noble_Oct17_2011_petrel2009_sav.ptd\Ocean* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct17_2011_petrel2009\Noble_Oct17_2011_petrel2009_sav.ptd\Ocean* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct17_2011_petrel2009\Noble_Oct17_2011_petrel2009_sav.ptd\OceanExtensionData* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct17_2011_petrel2009\Noble_Oct17_2011_petrel2009_sav.ptd\OceanExtensionData* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct17_2011_petrel2009\Noble_Oct17_2011_petrel2009_sav.stf.dat* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct17_2011_petrel2009\Noble_Oct17_2011_petrel2009_sav.stf.dat* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct18_2011_petrel2009* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct18_2011_petrel2009* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct18_2011_petrel2009\Noble_Oct18_2011_petrel2009_sav.ptd* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct18_2011_petrel2009\Noble_Oct18_2011_petrel2009_sav.ptd* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct18_2011_petrel2009\Noble_Oct18_2011_petrel2009_sav.ptd\Ocean* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct18_2011_petrel2009\Noble_Oct18_2011_petrel2009_sav.ptd\Ocean* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct18_2011_petrel2009\Noble_Oct18_2011_petrel2009_sav.ptd\OceanExtensionData* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct18_2011_petrel2009\Noble_Oct18_2011_petrel2009_sav.ptd\OceanExtensionData* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct18_2011_petrel2009\Noble_Oct18_2011_petrel2009_sav.stf.dat* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct18_2011_petrel2009\Noble_Oct18_2011_petrel2009_sav.stf.dat* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct19_2011_petrel2009* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct19_2011_petrel2009* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct19_2011_petrel2009\Noble_Oct19_2011_petrel2009_sav.ptd* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct19_2011_petrel2009\Noble_Oct19_2011_petrel2009_sav.ptd* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct19_2011_petrel2009\Noble_Oct19_2011_petrel2009_sav.ptd\Ocean* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct19_2011_petrel2009\Noble_Oct19_2011_petrel2009_sav.ptd\Ocean* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct19_2011_petrel2009\Noble_Oct19_2011_petrel2009_sav.ptd\OceanExtensionData* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct19_2011_petrel2009\Noble_Oct19_2011_petrel2009_sav.ptd\OceanExtensionData* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct19_2011_petrel2009\Noble_Oct19_2011_petrel2009_sav.stf.dat* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct19_2011_petrel2009\Noble_Oct19_2011_petrel2009_sav.stf.dat* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct6_2011_Petrel2009* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct6_2011_Petrel2009* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct6_2011_Petrel2009\Noble_Oct6_2011_Petrel2009.ptd* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct6_2011_Petrel2009\Noble_Oct6_2011_Petrel2009.ptd* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct6_2011_Petrel2009\Noble_Oct6_2011_Petrel2009.ptd\Ocean* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct6_2011_Petrel2009\Noble_Oct6_2011_Petrel2009.ptd\Ocean* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct6_2011_Petrel2009\Noble_Oct6_2011_Petrel2009.ptd\OceanExtensionData* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct6_2011_Petrel2009\Noble_Oct6_2011_Petrel2009.ptd\OceanExtensionData* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct6_2011_Petrel2009\Noble_Oct6_2011_Petrel2009.stf.dat* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\OffsetWellData*
*R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Petrel\Noble_Oct6_2011_Petrel2009\Noble_Oct6_2011_Petrel2009.stf.dat* - *R:\MEM\CurrentProjects\Noble\Larkridge_MA03-09D\Logs\FMI*

 
Many apologies, I have just figured out what the problem was. I was not including one very large folder that I intended for the program to ignore. The folders to be ignored are harvested from a listbox of all available folders. The user selects those to ignore. My bad. Again, many apologies and thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top