Sub MoveFiles()
Dim xFd As FileDialog
Dim xTFile As String
Dim xExtArr As Variant
Dim xExt As Variant
Dim xSPath As String
Dim xDPath As String
Dim xSFile As String
Dim xCount As Long
Set xFd = Application.FileDialog(msoFileDialogFolderPicker)
xFd.Title = "Please Select Original Folder:"
If xFd.Show = -1 Then
xSPath = xFd.SelectedItems(1)
Else
Exit Sub
End If
If Right(xSPath, 1) <> "\" Then xSPath = xSPath + "\"
xFd.Title = "Please Select Destination folder:"
If xFd.Show = -1 Then
xDPath = xFd.SelectedItems(1)
Else
Exit Sub
End If
If Right(xDPath, 1) <> "\" Then xDPath = xDPath + "\"
xExtArr = Array("*.xlsm*", "*.Docx")
For Each xExt In xExtArr
xTFile = Dir(xSPath & xExt)
Do While xTFile <> ""
xSFile = xSPath & xTFile
FileCopy xSFile, xDPath & xTFile
Kill xSFile
xTFile = Dir
xCount = xCount + 1
Loop
Next
MsgBox "Total number of moved files is: " & xCount, vbInformation, "Move File(S)"
End Sub
How it works:
- Copy & Paste this Code as Standard Module.
- RUN the Macro.
- It open the Explorer & prompt you to select
Original (Source) Folder.
- Select the Folder & Press OK.
- Again it prompt you to select the Destination
Folder.
- Press Ok, soon you get Message Box that how
many Files been copied.
Note:
- This line is editable
Array("*.xlsm*", "*.Docx")
, you may replace
File extensions
with other, as per your need.
Yes Excel VBA can facilitate you to drag file form Tree view to Folder !! – Rajesh S – 2018-09-07T11:45:06.593
Do you have any knowledge on how to do this? It would be much appreciated! Right now I have a query created from a folder located on a shared network drive which shows all the files located there. It could be really cool if it was possible to drag files directly into these different folders trough Excel without accessing them manually. – Sebastian – 2018-09-07T11:55:55.247
Give me some time to test the available VBA code, soon I'll return to the post. ☺ – Rajesh S – 2018-09-07T11:57:55.283
I've VBA code ready & working properly will help you to MOVE specific files from one to another folder, instead of DRAG them ! Will this work for you, just confirm so that I can post it here !! ☺ – Rajesh S – 2018-09-07T12:25:00.850
Sure, let me give it a try! :-) – Sebastian – 2018-09-07T12:37:17.207
Check the code I've posted just now after I've tried it successfully. ☺ – Rajesh S – 2018-09-07T12:55:03.340