Here is one way.
Sub x()
Dim oFile As Object
Dim oSubFolder As Object
Dim oFolderFile As Object
Dim strParentPath As String
Set oFile = CreateObject("Scripting.FileSystemObject")
strParentPath = "H:\VBA test\" 'change starting folder
With oFile
For Each oFolderFile In .GetFolder(strParentPath).Files
If Not .folderexists(Left(oFolderFile.Name, 6)) Then
.createfolder (Left(oFolderFile.Name, 6))
End If
.MoveFile oFolderFile, strParentPath & "\" & Left(oFolderFile.Name, 6) & "\"
Next oFolderFile
End With
End Sub
Bookmarks