Quote Originally Posted by anmac1789 View Post
which directory path are you testing this on ? I have done ?isarray(aryFoldersToExclude) and it returns false the error message. I also tested aryFoldersToExclude in the watch window and the value returned "out of context" and type - "empty".

So I've tested this on another computer and it seems to work. It seems that even after re-installing excel the code on my laptop doesn't work. What is going on here....

Also, it seems that in the sub isSpecificFileExcluded and isFolderExcluded the arguement inside UCase() should be changed to p.Path not p.name because paths are not being excluded properly, they were only excluding subfolder name and filename

here is the problem workbook so you can see for yourself if there are any changes compared to your workbook

Correcting / changing the two marked lines and entering

A1 = \\?\c:\users\daddy\downloads\very long folder path
C1 = hell yeah

seems to work


Private Function isFolderExcluded(p As Object) As Boolean
    Dim i As Long
    
    i = -1
    On Error Resume Next
    i = Application.WorksheetFunction.Match(UCase(p.Name), aryFoldersToExclude, 0)  '   <<<<<<<<<<<<<<<<<<<<<<<<<
    On Error GoTo 0


    isFolderExcluded = (i <> -1)
End Function


Private Function isFileExcluded(p As Object) As Boolean
    Dim i As Long
    
    i = -1
    On Error Resume Next
    i = Application.WorksheetFunction.Match(UCase(p.Name), aryFilenamesToExclude, 0)
    On Error GoTo 0


    isFileExcluded = (i <> -1)


End Function


Private Function isSpecificFileExcluded(p As Object) As Boolean
    Dim i As Long
    
    i = -1
    On Error Resume Next
    i = Application.WorksheetFunction.Match(UCase(p.Name), arySpecificFilesToExclude, 0)    '   <<<<<<<<<<<<<<<<<<<<<<
    On Error GoTo 0


    isSpecificFileExcluded = (i <> -1)


End Function