Thanks Westconn,

I had to make a few adjustments, but the code below works

However when I ran it against my current live directories, Circa 15,000+, it
took approx 10 Minutes to run.

Any ideas as to how it could be speeded up?

VB Code:
  1. Global arrfound()
  2. Sub findsubfolders(spath, spattern As String)
  3. Dim myfile As String, dirarr() As String, cnt As Long, i As Long
  4.  
  5. ReDim dirarr(100)
  6. cnt = 0
  7.     myfile = Dir(spath & "\*.*", vbDirectory)
  8.         Do While Not myfile = ""
  9.             If Not myfile = "." And Not myfile = ".." Then
  10.                 If (GetAttr(spath & "\" & myfile) And vbDirectory) <> 0 Then
  11.                     If LCase(myfile) Like LCase(spattern) Then
  12.                         If Not IsEmpty(arrfound(UBound(arrfound))) Then
  13.                             ReDim Preserve arrfound(UBound(arrfound) + 1)
  14.                         End If
  15.                         arrfound(UBound(arrfound)) = spath & "\" & myfile
  16.                     End If
  17.                     If cnt = UBound(dirarr) Then ReDim Preserve dirarr(UBound(dirarr) + 100)
  18.                     dirarr(cnt) = spath & "\" & myfile
  19.                     cnt = cnt + 1
  20. '               **** file search
  21. '               ElseIf LCase(myfile) Like LCase(spattern) Then dostuff spath & "\" & myfile
  22.                 End If
  23.             End If
  24.             myfile = Dir
  25.         Loop
  26.             If Not cnt = 0 Then
  27.                 cnt = cnt - 1
  28.                 ReDim Preserve dirarr(cnt)
  29.                     For i = 0 To UBound(dirarr)
  30.                         findsubfolders dirarr(i), spattern
  31.                     Next
  32.             End If
  33. End Sub
  34.  
  35. Sub findfile()
  36. 'set starting folder and files to match
  37. 'reset array
  38. Dim counter As Long
  39. Dim StartTime As Date
  40.     StartTime = Now
  41.     OutputRow = 1
  42.     CountRow = 1
  43. ReDim arrfound(0)
  44.     ThisWorkbook.Worksheets("Sheet1").Cells.Delete
  45.     ThisWorkbook.Worksheets("Sheet2").Cells.Delete
  46. Call findsubfolders("V:\Notes", "*10408*")
  47.  
  48. 'arrfound will now contain all the folders (complete path) in the tree below the starting folder, that match the pattern
  49.     If Not IsEmpty(arrfound) then
  50.         For counter = LBound(arrfound) To UBound(arrfound)
  51.             Debug.Print counter & " :: " & arrfound(counter)
  52.         Next counter
  53.     End if
  54.     Debug.Print StartTime & " :: " & Now
  55. End Sub