With such a procedure construction, you can not use the following line in the loop, because Dir function is silly. 
REFfolder = Dir(FDpath & "*" & REF, vbDirectory) & ""
https://docs.microsoft.com/office/vb...p/dir-function
In the function instructions we read:
You can change to a new pathname without retrieving all of the file names that match the current pathname. However,
you can't call the Dir function recursively. Calling Dir with the vbDirectory attribute does not continually return subdirectories.
To solve your problem, use the FileSystemObject from the Microsoft Scripting Runtime library.
Artik