I'm thinking this should work. The function MakeFolders is from my free code site, it will create the folder(s) as needed.
Option Explicit
Sub MOVEFILES()
'Jerry Beaucaire www.ExcelForum.com 1/22/2014
Dim fPATH As String, fNAME As String, fTYPE As String, fDEST As String
Dim Cnt As Long
fPATH = "C:\Path\To\Source\Files\" 'remember the final \ in this string
fTYPE = ".PDF" 'extension, filetype to find and move
fNAME = Dir(fPATH & "*" & fTYPE) 'get first filename
Do While Len(fNAME) > 0
Cnt = Cnt + 1 'increment counter
fDEST = "C:\" & Replace(fNAME, fTYPE, "") & "\Correspondence\" 'create destination string
MakeFolders (fDEST) 'create folders if needed
Name fPATH & fNAME As fDEST & fNAME 'move the file
fNAME = Dir 'get next filename
Loop 'lather, rinse, repeat
MsgBox Cnt & " file(s) have been transfered to their respective correspondence folders", vbInformation
End Sub
Function MakeFolders(MyStr As String)
'Author: Jerry Beaucaire
'Date: 7/14/2010
'Summary: Create directories and subdirectories based on the text strings fed to the function
' This version is to be called by other macros
' 10/19/2010 - International compliant
Dim MyArr As Variant, pNum As Long
Dim pBuf As String, Delim As String
On Error Resume Next
Delim = Application.PathSeparator
MyArr = Split(MyStr, Delim)
pBuf = MyArr(LBound(MyArr)) & Delim
For pNum = LBound(MyArr) + 1 To UBound(MyArr)
pBuf = pBuf & MyArr(pNum) & Delim
MkDir pBuf
Next pNum
End Function
Bookmarks