Μετάβαση στο κύριο περιεχόμενο

Πώς να αντιγράψετε ή να μετακινήσετε αρχεία από έναν φάκελο σε άλλο με βάση μια λίστα στο Excel; 

Εάν έχετε μια λίστα ονομάτων αρχείων σε μια στήλη σε ένα φύλλο εργασίας και τα αρχεία εντοπίζονται σε ένα φάκελο στον υπολογιστή σας. Ωστόσο, τώρα, πρέπει να μετακινήσετε ή να αντιγράψετε αυτά τα αρχεία, τα ονόματα που αναφέρονται στο φύλλο εργασίας από τον αρχικό τους φάκελο σε άλλο, όπως φαίνεται στο παρακάτω στιγμιότυπο οθόνης. Πώς θα μπορούσατε να ολοκληρώσετε αυτήν την εργασία όσο πιο γρήγορα μπορείτε στο Excel;

Αντιγράψτε ή μετακινήστε αρχεία από ένα φάκελο σε άλλο με βάση μια λίστα στο Excel με κώδικα VBA


Αντιγράψτε ή μετακινήστε αρχεία από ένα φάκελο σε άλλο με βάση μια λίστα στο Excel με κώδικα VBA

Για να μετακινήσετε τα αρχεία από έναν φάκελο σε έναν άλλο με βάση μια λίστα ονομάτων αρχείων, ο ακόλουθος κώδικας VBA μπορεί να σας βοηθήσει, κάντε το εξής:

1. Κρατήστε πατημένο το Alt + F11 στο Excel και ανοίγει το Microsoft Visual Basic για εφαρμογές παράθυρο.

2. Κλίκ Κύριο θέμα > Μονάδα μέτρησηςκαι επικολλήστε τον ακόλουθο κώδικα VBA στο Παράθυρο Module.

Κωδικός VBA: Μετακίνηση αρχείων από έναν φάκελο στον άλλο με βάση μια λίστα στο Excel

Sub movefiles()
'Updateby Extendoffice
    Dim xRg As Range, xCell As Range
    Dim xSFileDlg As FileDialog, xDFileDlg As FileDialog
    Dim xSPathStr As Variant, xDPathStr As Variant
    Dim xVal As String
    On Error Resume Next
    Set xRg = Application.InputBox("Please select the file names:", "KuTools For Excel", ActiveWindow.RangeSelection.Address, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    Set xSFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
    xSFileDlg.Title = " Please select the original folder:"
    If xSFileDlg.Show <> -1 Then Exit Sub
    xSPathStr = xSFileDlg.SelectedItems.Item(1) & "\"
    Set xDFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
    xDFileDlg.Title = " Please select the destination folder:"
    If xDFileDlg.Show <> -1 Then Exit Sub
    xDPathStr = xDFileDlg.SelectedItems.Item(1) & "\"
    For Each xCell In xRg
        xVal = xCell.Value
        If TypeName(xVal) = "String" And xVal <> "" Then
            FileCopy xSPathStr & xVal, xDPathStr & xVal
            Kill xSPathStr & xVal
        End If
    Next
End Sub

3. Και στη συνέχεια πατήστε F5 για να εκτελέσετε αυτόν τον κώδικα και θα εμφανιστεί ένα πλαίσιο προτροπής για να σας υπενθυμίσει ότι επιλέγετε τα κελιά που περιέχουν τα ονόματα αρχείων, δείτε το στιγμιότυπο οθόνης:

4. Στη συνέχεια κάντε κλικ στο κουμπί OK κουμπί και στο αναδυόμενο παράθυρο, επιλέξτε το φάκελο που περιέχει τα αρχεία από τα οποία θέλετε να μετακινηθείτε, δείτε το στιγμιότυπο οθόνης:

5. Και στη συνέχεια κάντε κλικ στο κουμπί OK, συνεχίστε επιλέγοντας το φάκελο προορισμού στον οποίο θέλετε να εντοπίσετε τα αρχεία σε άλλο αναδυόμενο παράθυρο, δείτε το στιγμιότυπο οθόνης:

6. Τέλος, κάντε κλικ στο κουμπί OK για να κλείσετε το παράθυρο και τώρα, τα αρχεία έχουν μετακινηθεί σε έναν άλλο φάκελο που καθορίσατε με βάση τα ονόματα αρχείων στη λίστα φύλλων εργασίας, δείτε το στιγμιότυπο οθόνης:

Note: Εάν θέλετε απλώς να αντιγράψετε τα αρχεία σε άλλο φάκελο, αλλά να διατηρήσετε τα αρχικά αρχεία, εφαρμόστε τον παρακάτω κώδικα VBA:

Κωδικός VBA: Αντιγράψτε αρχεία από έναν φάκελο σε έναν άλλο με βάση μια λίστα στο Excel

Sub copyfiles()
'Updateby Extendoffice
    Dim xRg As Range, xCell As Range
    Dim xSFileDlg As FileDialog, xDFileDlg As FileDialog
    Dim xSPathStr As Variant, xDPathStr As Variant
    Dim xVal As String
    On Error Resume Next
    Set xRg = Application.InputBox("Please select the file names:", "KuTools For Excel", ActiveWindow.RangeSelection.Address, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    Set xSFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
    xSFileDlg.Title = "Please select the original folder:"
    If xSFileDlg.Show <> -1 Then Exit Sub
    xSPathStr = xSFileDlg.SelectedItems.Item(1) & "\"
    Set xDFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
    xDFileDlg.Title = "Please select the destination folder:"
    If xDFileDlg.Show <> -1 Then Exit Sub
    xDPathStr = xDFileDlg.SelectedItems.Item(1) & "\"
    For Each xCell In xRg
        xVal = xCell.Value
        If TypeName(xVal) = "String" And xVal <> "" Then
            FileCopy xSPathStr & xVal, xDPathStr & xVal
        End If
    Next
End Sub

 

Τα καλύτερα εργαλεία παραγωγικότητας γραφείου

🤖 Kutools AI Aide: Επανάσταση στην ανάλυση δεδομένων με βάση: Ευφυής Εκτέλεση   |  Δημιουργία κώδικα  |  Δημιουργία προσαρμοσμένων τύπων  |  Αναλύστε δεδομένα και δημιουργήστε γραφήματα  |  Επίκληση Λειτουργιών Kutools...
Δημοφιλή χαρακτηριστικά: Εύρεση, επισήμανση ή αναγνώριση διπλότυπων   |  Διαγραφή κενών γραμμών   |  Συνδυάστε στήλες ή κελιά χωρίς απώλεια δεδομένων   |   Γύρος χωρίς φόρμουλα ...
Σούπερ Αναζήτηση: VLookup πολλαπλών κριτηρίων    VLookup πολλαπλών τιμών  |   VLookup σε πολλά φύλλα   |   Ασαφής αναζήτηση ....
Σύνθετη αναπτυσσόμενη λίστα: Γρήγορη δημιουργία αναπτυσσόμενης λίστας   |  Εξαρτημένη αναπτυσσόμενη λίστα   |  Πολλαπλή αναπτυσσόμενη λίστα ....
Διαχειριστής στήλης: Προσθέστε έναν συγκεκριμένο αριθμό στηλών  |  Μετακίνηση στηλών  |  Εναλλαγή κατάστασης ορατότητας κρυφών στηλών  |  Συγκρίνετε εύρη και στήλες ...
Επιλεγμένα Χαρακτηριστικά: Εστίαση πλέγματος   |  Προβολή σχεδίου   |   Μεγάλη Formula Bar    Διαχείριση βιβλίου εργασίας & φύλλου   |  Βιβλιοθήκη πόρων (Αυτόματο κείμενο)   |  Επιλογή ημερομηνίας   |  Συνδυάστε φύλλα εργασίας   |  Κρυπτογράφηση/Αποκρυπτογράφηση κελιών    Αποστολή email ανά λίστα   |  Σούπερ φίλτρο   |   Ειδικό φίλτρο (φίλτρο με έντονη γραφή/πλάγια γραφή/διαγραφή...) ...
Κορυφαία 15 σύνολα εργαλείων12 Κείμενο Εργαλεία (Προσθήκη κειμένου, Κατάργηση χαρακτήρων, ...)   |   50 + Διάγραμμα Τύποι (Gantt διάγραμμα, ...)   |   40+ Πρακτικό ΜΑΘΗΜΑΤΙΚΟΙ τυποι (Υπολογίστε την ηλικία με βάση τα γενέθλια, ...)   |   19 Εισαγωγή Εργαλεία (Εισαγωγή κωδικού QR, Εισαγωγή εικόνας από το μονοπάτι, ...)   |   12 Μετατροπή Εργαλεία (Αριθμοί σε λέξεις, Μετατροπή Συναλλάγματος, ...)   |   7 Συγχώνευση & διαχωρισμός Εργαλεία (Σύνθετες σειρές συνδυασμού, Διαίρεση κελιών, ...)   |   ... κι αλλα

Αυξήστε τις δεξιότητές σας στο Excel με τα Kutools για Excel και απολαύστε την αποτελεσματικότητα όπως ποτέ πριν. Το Kutools για Excel προσφέρει πάνω από 300 προηγμένες δυνατότητες για την ενίσχυση της παραγωγικότητας και την εξοικονόμηση χρόνου.  Κάντε κλικ εδώ για να αποκτήσετε τη δυνατότητα που χρειάζεστε περισσότερο...

Περιγραφή


Το Office Tab φέρνει τη διεπαφή με καρτέλες στο Office και κάνει την εργασία σας πολύ πιο εύκολη

  • Ενεργοποίηση επεξεργασίας και ανάγνωσης καρτελών σε Word, Excel, PowerPoint, Publisher, Access, Visio και Project.
  • Ανοίξτε και δημιουργήστε πολλά έγγραφα σε νέες καρτέλες του ίδιου παραθύρου και όχι σε νέα παράθυρα.
  • Αυξάνει την παραγωγικότητά σας κατά 50% και μειώνει εκατοντάδες κλικ του ποντικιού για εσάς κάθε μέρα!

 

Comments (74)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hy skyyang and hy everybody!
I have found this page and the macro that copies files from folder and subfolder was really amazing!!
I would like to ask, if possible, how to change this macro to have the possibility to digit only the first 10 characters of the file name (and no extension).
For example:
my input for search would be “+AE704706P” and the folder, or subfolders, could contain “+AE704706P_03.pdf” “+AE704706P_03.dwg”.
I would need to copy all files starting with those 10 characters.
Thank you in advance for your attention, I hope I was clear enough...;-)

The macro that I am currently using for which I am asking your help is the following one:

Sub Copyfiles()
'Updateby Extendoffice
Dim xRg As Range, xCell As Range
Dim xSFileDlg As FileDialog, xDFileDlg As FileDialog
Dim xSPathStr As Variant, xDPathStr As Variant
Dim xVal As String
Dim fso As Object, folder1 As Object
Set xRg = Application.InputBox("Please select the file names:", "KuTools For Excel", ActiveWindow.RangeSelection.Address, , , , , 8)
If xRg Is Nothing Then Exit Sub
Set xSFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
xSFileDlg.Title = " Please select the original folder:"
If xSFileDlg.Show <> -1 Then Exit Sub
xSPathStr = xSFileDlg.SelectedItems.Item(1) & "\"
Set xDFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
xDFileDlg.Title = " Please select the destination folder:"
If xDFileDlg.Show <> -1 Then Exit Sub
xDPathStr = xDFileDlg.SelectedItems.Item(1) & "\"
Call sCopyFiles(xRg, xSPathStr, xDPathStr)
End Sub

Sub sCopyFiles(xRg As Range, xSPathStr As Variant, xDPathStr As Variant)
Dim xCell As Range
Dim xVal As String
Dim xFolder As Object
Dim fso As Object
Dim xF As Object
Dim xStr As String
Dim xFS As Object
Dim xI As Integer
On Error Resume Next
If Dir(xDPathStr, vbDirectory) = "" Then
MkDir (xDPathStr)
End If
For xI = 1 To xRg.Count
Set xCell = xRg.Item(xI)
xVal = xCell.Value
If TypeName(xVal) = "String" And Not (xVal = "") Then
On Error GoTo E1
If Dir(xSPathStr & xVal, 16) <> Empty Then
FileCopy xSPathStr & xVal, xDPathStr & xVal
End If
End If
E1:
Next xI
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set xFS = fso.GetFolder(xSPathStr)
For Each xF In xFS.SubFolders
xStr = xDPathStr '& "\" & xF.Name
Call sCopyFiles(xRg, xF.ShortPath & "\", xStr & "\")
If (CreateObject("scripting.FileSystemObject").GetFolder(xStr).Files.Count = 0) _
And (CreateObject("scripting.FileSystemObject").GetFolder(xStr).SubFolders.Count = 0) Then
RmDir xStr
End If
Next
End Sub
This comment was minimized by the moderator on the site
Good afternoon!
In this topic, I found a script that moves folders, subfolders along with files based on the list of folder names in Excel, but is there a script that does not move, but simply copies folders and subfolders along with files?
This comment was minimized by the moderator on the site
Hello, Serg,
To copy the files from the folder and subfolders, please apply the below code:


Sub movefiles()
'Updateby Extendoffice
Dim xRg As Range, xCell As Range
Dim xSFileDlg As FileDialog, xDFileDlg As FileDialog
Dim xSPathStr As Variant, xDPathStr As Variant
Dim xVal As String
Dim fso As Object, folder1 As Object
' On Error Resume Next
Set xRg = Application.InputBox("Please select the file names:", "KuTools For Excel", ActiveWindow.RangeSelection.Address, , , , , 8)
If xRg Is Nothing Then Exit Sub
Set xSFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
xSFileDlg.Title = " Please select the original folder:"
If xSFileDlg.Show <> -1 Then Exit Sub
xSPathStr = xSFileDlg.SelectedItems.Item(1) & "\"
Set xDFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
xDFileDlg.Title = " Please select the destination folder:"
If xDFileDlg.Show <> -1 Then Exit Sub
xDPathStr = xDFileDlg.SelectedItems.Item(1) & "\"
Call sMoveFiles(xRg, xSPathStr, xDPathStr)
End Sub

Sub sMoveFiles(xRg As Range, xSPathStr As Variant, xDPathStr As Variant)
Dim xCell As Range
Dim xVal As String
Dim xFolder As Object
Dim fso As Object
Dim xF As Object
Dim xStr As String
Dim xFS As Object
Dim xI As Integer
On Error Resume Next
If Dir(xDPathStr, vbDirectory) = "" Then
MkDir (xDPathStr)
End If
For xI = 1 To xRg.Count
Set xCell = xRg.Item(xI)
xVal = xCell.Value
If TypeName(xVal) = "String" And Not (xVal = "") Then
On Error GoTo E1
If Dir(xSPathStr & xVal, 16) <> Empty Then
FileCopy xSPathStr & xVal, xDPathStr & xVal
'Kill xSPathStr & xVal
End If
End If
E1:
Next xI
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set xFS = fso.GetFolder(xSPathStr)
For Each xF In xFS.SubFolders
xStr = xDPathStr & "\" & xF.Name ' Replace(xF.ShortPath, xSPathStr, xDPathStr)
Call sMoveFiles(xRg, xF.ShortPath & "\", xStr & "\")
If (CreateObject("scripting.FileSystemObject").GetFolder(xStr).Files.Count = 0) _
And (CreateObject("scripting.FileSystemObject").GetFolder(xStr).SubFolders.Count = 0) Then
RmDir xStr
End If
Next
End Sub



Please have a try, thank you!
This comment was minimized by the moderator on the site
Good afternoon!
In this topic, I found a script that moves folders, subfolders along with files based on the list of folder names in Excel, but is there a script that does not move files and folders, but simply copies folders and subfolders along with files?
This comment was minimized by the moderator on the site
Hello! I came here by accident looking for a file copy macro. Thank you for what I found! This macro is amazing! However, I would like to modify them a bit - is it possible to change something in the code so that the files to be transferred are always taken from the same lohalization?
This comment was minimized by the moderator on the site
Hello, Łukasz
To fix the folder locations, please apply the below code:
Sub movefiles()
'Updateby Extendoffice
    Dim xRg As Range, xCell As Range
    Dim xSPathStr As Variant, xDPathStr As Variant
    Dim xVal As String
    On Error Resume Next
    Set xRg = Application.InputBox("Please select the file names:", "KuTools For Excel", ActiveWindow.RangeSelection.Address, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    xSPathStr = "C:\Users\AddinsVM001\Desktop\Folder-1\"  'Original folder
    xDPathStr = "C:\Users\AddinsVM001\Desktop\Folder-2\"  'destination folder
    For Each xCell In xRg
        xVal = xCell.Value
        If TypeName(xVal) = "String" And xVal <> "" Then
            FileCopy xSPathStr & xVal, xDPathStr & xVal
            Kill xSPathStr & xVal
        End If
    Next
End Sub


Please have a try, hope it can help you!
This comment was minimized by the moderator on the site
ad ơi mình k chuyển đc file pdf, excel hoặc các file khác vẫn chuyển đc, giúp mình vs ạ.T_T
This comment was minimized by the moderator on the site
Hello, Huong,
The code works well in my workbook. Did you add the file extension after the file name in your list?
Or you can upload your screenshot here, so that, we can check where the problem is.
Thank you!
This comment was minimized by the moderator on the site
Hello! Can anybody help me to fix this code to use it for copy .pdf files. This code works greate for .png or .jpg files, but doesn't work with pdf.

Sub Copyfiles()
'Updateby Extendoffice
Dim xRg As Range, xCell As Range
Dim xSFileDlg As FileDialog, xDFileDlg As FileDialog
Dim xSPathStr As Variant, xDPathStr As Variant
Dim xVal As String
Dim fso As Object, folder1 As Object
' On Error Resume Next
Set xRg = Application.InputBox("Please select the file names:", "KuTools For Excel", ActiveWindow.RangeSelection.Address, , , , , 8)
If xRg Is Nothing Then Exit Sub
Set xSFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
xSFileDlg.Title = " Please select the original folder:"
If xSFileDlg.Show <> -1 Then Exit Sub
xSPathStr = xSFileDlg.SelectedItems.Item(1) & "\"
Set xDFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
xDFileDlg.Title = " Please select the destination folder:"
If xDFileDlg.Show <> -1 Then Exit Sub
xDPathStr = xDFileDlg.SelectedItems.Item(1) & "\"
Call sCopyFiles(xRg, xSPathStr, xDPathStr)
End Sub

Sub sCopyFiles(xRg As Range, xSPathStr As Variant, xDPathStr As Variant)
Dim xCell As Range
Dim xVal As String
Dim xFolder As Object
Dim fso As Object
Dim xF As Object
Dim xStr As String
Dim xFS As Object
Dim xI As Integer
On Error Resume Next
If Dir(xDPathStr, vbDirectory) = "" Then
MkDir (xDPathStr)
End If
For xI = 1 To xRg.Count
Set xCell = xRg.Item(xI)
xVal = xCell.Value
If TypeName(xVal) = "String" And Not (xVal = "") Then
On Error GoTo E1
If Dir(xSPathStr & xVal, 16) <> Empty Then
FileCopy xSPathStr & xVal, xDPathStr & xVal
End If
End If
E1:
Next xI
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set xFS = fso.GetFolder(xSPathStr)
For Each xF In xFS.SubFolders
xStr = xDPathStr '& "\" & xF.Name ' Replace(xF.ShortPath, xSPathStr, xDPathStr)
Call sCopyFiles(xRg, xF.ShortPath & "\", xStr & "\")
If (CreateObject("scripting.FileSystemObject").GetFolder(xStr).Files.Count = 0) _
And (CreateObject("scripting.FileSystemObject").GetFolder(xStr).SubFolders.Count = 0) Then
RmDir xStr
End If
Next
End Sub
This comment was minimized by the moderator on the site
I like this solution but my case is, I want to move the sub-folder to destination folders not the file. Has anyone figure this out?
This comment was minimized by the moderator on the site
Hello, Senthil
To move subfolders from one one to another, please apply the below VBA code:
Sub movefolders()
'Updateby Extendoffice
Dim xRg As Range, xCell As Range
Dim xSFileDlg As FileDialog
Dim xSPathStr As Variant, xDPathStr As Variant
Dim xVal As String
Dim xFs

On Error Resume Next
Set xRg = Application.InputBox("Please select the folder names:", "KuTools For Excel", ActiveWindow.RangeSelection.Address, , , , , 8)
If xRg Is Nothing Then Exit Sub

Set xSFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
xSFileDlg.Title = "Select the original folder:"
If xSFileDlg.Show <> -1 Then Exit Sub
xSPathStr = xSFileDlg.SelectedItems.Item(1) & "\"

Set xSFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
xSFileDlg.Title = "Select the destination folder:"
If xSFileDlg.Show <> -1 Then Exit Sub
xDPathStr = xSFileDlg.SelectedItems.Item(1) & "\"

Set xFs = CreateObject("Scripting.FileSystemObject")

For Each xCell In xRg
xVal = xCell.Value
If TypeName(xVal) = "String" And xVal <> "" Then
xFs.MoveFolder xSPathStr & xVal, xDPathStr & xVal
End If
Next
End Sub


Please have a try, hope it can help you!
This comment was minimized by the moderator on the site
Actuallly i want move folder from one loction to another Based On A List In Excel, but i m not able do it that one.
Kindly help on this please.
This comment was minimized by the moderator on the site
Hello, Suhas,
Have you add the file extensions at the end of of the file names? Please check it.
If you still have the problem, please comment here. Or you can insert your data screenshot here.
This comment was minimized by the moderator on the site
Hi,

I want to ask is it possible if I want to change the set xRg = Application.InputBox to directly check the file name in the column A1?

Set xRg = Application.InputBox("Please select the file names:", "KuTools For Excel", ActiveWindow.RangeSelection.Address, , , , , 8)
If xRg Is Nothing Then Exit Sub
This comment was minimized by the moderator on the site
Hello, botAlu

If you don't want to pop out the first promp box,
you just need to change the script "Set xRg = Application.InputBox("Please select the file names:", "KuTools For Excel", ActiveWindow.RangeSelection.Address, , , , , 8)" to "Set xRg = Range("A1:A10")".
Note: A1:A10 is the list of cells contain the file name, you can change the cell reference to your own.

Please try, hope it can help you!
This comment was minimized by the moderator on the site
Alguém conseguiu adaptar para não precisar de extensão?


Has anyone managed to adapt so that it is not necessary to use the extension?
This comment was minimized by the moderator on the site
Hello, Raphael
Copying the files from one folder to another without considering the file extension, you should apply the following code:
Sub copyfiles2()
'Updateby Extendoffice
    Dim xRg As Range, xCell As Range
    Dim xSFileDlg As FileDialog, xDFileDlg As FileDialog
    Dim xSPathStr As Variant, xDPathStr As Variant
    Dim xVal, xStrPath As String
    On Error Resume Next
    Set xRg = Application.InputBox("Please select the file names:", "KuTools For Excel", ActiveWindow.RangeSelection.Address, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    Set xSFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
    xSFileDlg.Title = " Please select the original folder:"
    If xSFileDlg.Show <> -1 Then Exit Sub
    xSPathStr = xSFileDlg.SelectedItems.Item(1) & "\"
    Set xDFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
    xDFileDlg.Title = " Please select the destination folder:"
    If xDFileDlg.Show <> -1 Then Exit Sub
    xDPathStr = xDFileDlg.SelectedItems.Item(1) & "\"
    For Each xCell In xRg
        xVal = xCell.Value
        If TypeName(xVal) = "String" And xVal <> "" Then
            xStrPath = xSPathStr
            xStrTmp = Dir(xStrPath & xVal & ".*", vbDirectory)
            Do While xStrTmp <> ""
                Debug.Print xStrPath & xStrTmp
                FileCopy xSPathStr & xStrTmp, xDPathStr & xStrTmp
                xStrTmp = Dir
            Loop
        End If
    Next
End Sub

Please try, hope it can help you!
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations