What is the definition of 'duplicate' over different runs?
What I mean is, running the code recursively lists all folders/files and repeats the list after each subsequent run producing duplicate entries for the same parent folder. Basically it is this piece of code here:
Private Sub RemoveDups()
Dim rowNew As Long
For rowNew = wsOut.Cells(1, 1).CurrentRegion.Rows.Count To rPrev.Rows.Count + 1 Step -1
If Application.WorksheetFunction.CountIf(rPrev.Columns(colParent), wsOut.Cells(rowNew, colParent).Value) > 0 Then
'mark special
wsOut.Cells(rowNew, colParent).Value = True
End If
Next rowNew
On Error Resume Next
wsOut.Columns(colParent).SpecialCells(xlCellTypeConstants, xlLogical).EntireRow.Delete
On Error GoTo 0
End Sub
However, I just thought of something. What if I produce a list of files and folders for a parent directory in run 1 but want to exclude a folder path AFTER run 1 for run 2 and shorten the results? Would I just need to add another code or can I extend the above code?
Didn't understand your pictures
With spaces / without spaces don't matter
Test 1 - Do first run and it's Excludes, save copy of Files worksheet as Files-1, and clear Files WS. Is it correct?
Test 2 - Do second run and it's Excludes, save Files worksheet as Files-2, , and clear Files WS.Is it correct?
Test 3 - Do run 1 and it's excludes and then do run 2 it's Excludes. Is it correct?
The reason for the spaces inside the folder names is just something random I did, i understand it doesn't matter and that excel vba accepts spaces in file/folder names. The pictures demonstrate that after run 2, a folder from run 1 was deleted. I am attaching a workbook which explains what those pictures mean