Note: The other languages of the website are Google-translated. Back to English
Inloggen  \/ 
x
or
x
Registreer  \/ 
x

or

Hoe bestanden van de ene map naar de andere te kopiëren of te verplaatsen op basis van een lijst in Excel? 

Als u een lijst met bestandsnamen in een kolom in een werkblad heeft en de bestanden zich in een map op uw computer bevinden. Maar nu moet u deze bestanden verplaatsen of kopiëren waarvan de namen in het werkblad worden vermeld van hun oorspronkelijke map naar een andere zoals in het volgende screenshot. Hoe kon je deze taak zo snel mogelijk voltooien in Excel?

Kopieer of verplaats bestanden van de ene map naar de andere op basis van een lijst in Excel met VBA-code


Kopieer of verplaats bestanden van de ene map naar de andere op basis van een lijst in Excel met VBA-code

Om de bestanden van de ene map naar de andere te verplaatsen op basis van een lijst met bestandsnamen, kan de volgende VBA-code u een plezier doen, doe dit als volgt:

1. Houd de Alt + F11 toetsen in Excel, en het opent het Microsoft Visual Basic voor toepassingen venster.

2. Klikken Invoegen > Moduleen plak de volgende VBA-code in het modulevenster.

VBA-code: verplaats bestanden van de ene map naar de andere op basis van een lijst in 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. En druk vervolgens op F5 sleutel om deze code uit te voeren, en er verschijnt een promptvenster om u eraan te herinneren de cellen te selecteren die de bestandsnamen bevatten, zie screenshot:

4. Dan klikken OK knop, en selecteer in het uitgeklapte venster de map die de bestanden bevat waaruit u wilt verplaatsen, zie screenshot:

5. En klik vervolgens op OK, ga door met het selecteren van de bestemmingsmap waar u de bestanden wilt lokaliseren in een ander uitgeklapt venster, zie screenshot:

6. Klik ten slotte op OK om het venster te sluiten, en nu zijn de bestanden verplaatst naar een andere map die u hebt opgegeven op basis van de bestandsnamen in de werkbladlijst, zie screenshot:

Opmerking:: Als u de bestanden alleen naar een andere map wilt kopiëren, maar de originele bestanden wilt behouden, past u de onderstaande VBA-code toe:

VBA-code: kopieer bestanden van de ene map naar de andere op basis van een lijst in 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

De beste tools voor kantoorproductiviteit

Kutools voor Excel lost de meeste van uw problemen op en verhoogt uw productiviteit met 80%

  • visfuik: Snel invoegen complexe formules, grafieken en alles wat je eerder hebt gebruikt; Versleutel cellen met wachtwoord; Maak een mailinglijst en stuur e-mails ...
  • Super Formula-balk (bewerk eenvoudig meerdere regels tekst en formule); Lay-out lezen (gemakkelijk grote aantallen cellen lezen en bewerken); Plakken in gefilterd bereik...
  • Voeg cellen / rijen / kolommen samen zonder gegevens te verliezen; Gespleten cellen inhoud; Combineer dubbele rijen / kolommen... Voorkom dubbele cellen; Vergelijk Ranges...
  • Selecteer Dupliceren of Uniek Rijen; Selecteer lege rijen (alle cellen zijn leeg); Super zoeken en fuzzy zoeken in veel werkboeken; Willekeurige selectie ...
  • Exacte kopie Meerdere cellen zonder de formuleverwijzing te wijzigen; Maak automatisch verwijzingen naar meerdere bladen; Plaats kogels, Selectievakjes en meer ...
  • Extraheer tekst, Tekst toevoegen, Verwijderen op positie, Ruimte verwijderen; Paging-subtotalen maken en afdrukken; Converteren tussen celinhoud en opmerkingen...
  • Super filter (bewaar en pas filterschema's toe op andere bladen); Geavanceerd sorteren per maand / week / dag, frequentie en meer; Speciaal filter door vet, cursief ...
  • Combineer werkmappen en werkbladen; Tabellen samenvoegen op basis van sleutelkolommen; Gegevens splitsen in meerdere bladen; Batch Converteer xls, xlsx en PDF...
  • Meer dan 300 krachtige functies. Ondersteunt Office / Excel 2007-2019 en 365. Ondersteunt alle talen. Eenvoudig te implementeren in uw onderneming of organisatie. Gratis proefperiode van 30 dagen met volledige functies. 60 dagen geld-terug-garantie.
kte tabblad 201905

Office-tabblad Brengt een interface met tabbladen naar Office en maakt uw werk veel gemakkelijker

  • Schakel bewerken en lezen met tabbladen in Word, Excel, PowerPoint in, Publisher, Access, Visio en Project.
  • Open en maak meerdere documenten in nieuwe tabbladen van hetzelfde venster in plaats van in nieuwe vensters.
  • Verhoogt uw productiviteit met 50% en vermindert elke dag honderden muisklikken voor u!
officetab onderkant
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Evelyne · 15 days ago
    Everything was OK for me (800 files to copy from a folder containing 10000 files).
    Many thanks.
  • To post as a guest, your comment is unpublished.
    marc_vie · 1 months ago
    Excellent macro.
    How can this be modified for my need case as below. I have zero experience in VBA.
    The source folders (3 – zmf, vek, num) and destination folders (4 – jack, james, john, jane) names and paths are constant.
    Source folders (3)
    \\192.168.xx.x\ma\zmf\ (files here – 123.wav, 456.wav, etc)
    \\192.168.xx.x\ma\vek\ (files here – abc.wav, etc)
    \\192.168.xx.x\ma\num\ (files here – ghi.wav, etc)
    Destination folders (4)
    \\192.168.xx.xx\ba\jack\
    \\192.168.xx.xx\ba\james\
    \\192.168.xx.xx\ba\john\
    \\192.168.xx.xx\ba\jane\
    In Excel sheet, in Column A I have the list of files (will change on a daily basis) which have to be COPIED (not moved) to the folder in Column B (the folder in which the files are contained (zmf, vek, num) also have to be copied.
    For example, 123.wav has to be copied to the folder “jack” such as \\192.168.xx.xx\ba\jack\zmf\123.wav
        abc.wav has to be copied to the folder “jane” such as \\192.168.xx.xx\ba\jane\vek\abc.wav
        ghi.wav also has to be copied to the folder “jack” such as \\192.168.xx.xx\ba\jack\num\ghi.wav
        
    Column A    Column B
    Files in Source folders    Destination folders (constant)
    123.wav    jack
    456.wav    james
    789.wav    john
    abc.wav    jane
    def.wav    james
    ghi.wav    jack

    Can anyone help with modifying this macro please?
  • To post as a guest, your comment is unpublished.
    G · 7 months ago
    I have a list of 10000 files that need to be moved but the above code stops after taking source file location. Kindly let me know if I need to change anything in the code.
  • To post as a guest, your comment is unpublished.
    enesa20 · 9 months ago
    Hello,
    I need some additional help with the VBA code.

    My excel list has names like this:

    ABCDEF

    The .jpg files Im trying to match are:

    ABCDEF_1, ABCDEF_2, ABCDEF_3 ....

    Some names on the list has more than 1 .jpg files and I want ALL of those files to be copied. Could anybody please modify the code accordingly?,,

    Thank you very much!!
  • To post as a guest, your comment is unpublished.
    Walter · 9 months ago
    Hallo,
    what must i change when i always want to search pdf and jpg files and then copy thes in only one destination folder?
  • To post as a guest, your comment is unpublished.
    Joelle · 9 months ago
    Thank you! you are a life saver!
  • To post as a guest, your comment is unpublished.
    Puneet Goel · 11 months ago
    Thanks a lot.....It really worked very well and solved the issue completely
  • To post as a guest, your comment is unpublished.
    Steve · 11 months ago
    Can anyone help to adapt the code to search specific files in folder and subfolers then copy it to destination?
    • To post as a guest, your comment is unpublished.
      skyyang · 11 months ago
      Hello, Steve,
      To copy the files from one folder including the subfolders to another folder based on the list in sheet, please apply the following code.
      Please try, hope it can help you!
      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

      • To post as a guest, your comment is unpublished.
        HelpMe · 9 months ago
        Can You help me with this? I copied the whole code and it's fine but I'd like to use only part of the file name and not create folder when copyiong file from subfolder. Let's say I have folder AAA with file 123-321.pdf and subfolder BBB with file 123_111.pdf
        In Excel column i have only "123" without any extension or "-" or "_" and I want to copy all files containing "123" from folder AAA to new folder CCC.

        Right now this code would only copy a files when the full name is written in excel column like "123-321.pdf" or would create whole new subfolder BBB in folder CCC if you look for "123_111.pdf"

        Looking forward to Your response as I'm not even a newbie in VBA just passing by :D
  • To post as a guest, your comment is unpublished.
    priya · 1 years ago
    works perfectly like a charm
  • To post as a guest, your comment is unpublished.
    sd · 1 years ago
    can anyone help to adapt this excellent code so the file range is fixed eg all filenames in column A until empty cell and pre set the from path as i always copy from the same source
    • To post as a guest, your comment is unpublished.
      mubashirazizch@gmail.com · 1 years ago
      use this code and keep A1 cell blank

      Sub Copymy1()
      Dim filelist As Variant
      Dim i As Long
      Dim filetocopy As String
      Dim copysource As String
      Dim Copydestination As String

      copysource = "C:\copyfrom\"
      Copydestination = "C:copyto\"
      filelist = ActiveWorkbook.Sheets(1).Range("A1").CurrentRegion.Value
      For i = 2 To UBound(filelist)
      FName = Dir$(copysource & "*.*")
      While FName <> ""
      If UCase(FName) = UCase(filelist(i, 1)) Then
      FileCopy copysource & FName, Copydestination & FName

      End If
      FName = Dir$()
      Wend
      Next i

      End Sub
  • To post as a guest, your comment is unpublished.
    Exe · 1 years ago
    Sorry I just saw the second script below...

    I do have one more (applicable) query... Is there a way to make the script pick a filtered selection on a column? Instead of consecutive cell ranges.. would there be a way to make it pick only some specific rows after a filter is applied?
    THANK YOU
  • To post as a guest, your comment is unpublished.
    Exe · 1 years ago
    Thank you SO MUCH for this. It worked perfectly at my end.
    I have one question... is it possible to modify this to copy the files into the second path instead of moving them? I would need to apply this feature but I do need the source files to remain in the source folders.
    Thank you!!!
  • To post as a guest, your comment is unpublished.
    Phil · 1 years ago
    Hi, Can this code be tweaked to look for partial file names using a wildcard? Thanks
  • To post as a guest, your comment is unpublished.
    sabin348 · 1 years ago
    How could this be adapted to paste into a list of multiple file paths instead of one path at a time?
    • To post as a guest, your comment is unpublished.
      skyyang · 1 years ago
      Hello, sabin,
      Do you want to copy and paste the files which from multiple original folders instead of only one folder?
      • To post as a guest, your comment is unpublished.
        andrea · 1 years ago
        yes please

  • To post as a guest, your comment is unpublished.
    mmarques09 · 1 years ago
    If the reference doesn't exist the code break
    wich line shall I had to the code do a jump through the next reference without stop
  • To post as a guest, your comment is unpublished.
    Marco · 1 years ago
    An what happen if the file doesn't existe in the origin folder?
    the code breaks

    The code shall has a line to jump to another reference if doesn't exist
  • To post as a guest, your comment is unpublished.
    Kevin · 1 years ago
    HI, I am not an expert in VBA but need your Module and I did as you instruct but nothing copied from source folder to the new folder. and no error is shown
  • To post as a guest, your comment is unpublished.
    inasr · 2 years ago
    Any update of how to search on folder and subfolders
    • To post as a guest, your comment is unpublished.
      skyyang · 2 years ago
      Hi, Nasr,
      To move files from folder and subfolders based on cell values, please apply the below VBA code:
      Please try, hope it can help you!

      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
      • To post as a guest, your comment is unpublished.
        Anita Singh · 7 months ago
        Hi skyyang,
        I want to copy or move files (.jpg, .png) any format from folder & its sub-folders. The above script is copying the whole folder containing the matched file

        Thanks & Regards,

      • To post as a guest, your comment is unpublished.
        inasr · 2 years ago
        That's perfect thank you
        but what about if I just wanted to copy files not moving it from subfolders only without the need of creating subfolders in the destination folder
        ie
        source folder X:\\parent
        inside parent is subfolders test1(file A), test2(file B) and test3(file C)
        then destination folder is "Y:\\destination" has all 3 files A, B, C without the subfolders

        Thank you very much
        • To post as a guest, your comment is unpublished.
          Mike · 1 years ago
          Hi Nasr, did you figure out how to do this? I am looking at a similar need at the moment.

          Copying a selection of files from various subfolders to a single folder
          • To post as a guest, your comment is unpublished.
            inasr · 1 years ago
            Hi Mike
            I kind of did BUT indirectly, so what I did is modify the code to copy the files not move them with the subfolder
            then with CMD file move the file from subfolders to the main folder then delete the empty subfolder
            this is what I did

            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



            then copy the following lines to a new notepad then save it as cmd call it whatever

            for /r %%a IN (*.*) do (
            move /y "%%a" "%cd%"
            )
            for /f "delims=" %%d in ('dir /s /b /ad ^| sort /r') do rd "%%d"



            make sure to copy the code as is 4 lines
            hope that help
            • To post as a guest, your comment is unpublished.
              Tim · 1 years ago
              You can achieve the same result using only the VBA if you add a ' before the & "\" & xF.Name in the below line.
              This still copies from subfolders but copies to a single level folder.

              xStr = xDPathStr & "\" & xF.Name ' Replace(xF.ShortPath, xSPathStr, xDPathStr)
              Becomes
              xStr = xDPathStr '& "\" & xF.Name ' Replace(xF.ShortPath, xSPathStr, xDPathStr)
            • To post as a guest, your comment is unpublished.
              inasr · 1 years ago
              make sure to put the cmd file in the same folder that you copy the files and subfolders to then double click it
  • To post as a guest, your comment is unpublished.
    ADOLFO · 2 years ago
    buenas noches, alguien sabe que tengo que modificar para que me mueva carpetas y no solo archivos?
  • To post as a guest, your comment is unpublished.
    jonathan · 2 years ago
    thanks so much !
  • To post as a guest, your comment is unpublished.
    Michael · 2 years ago
    Has anyone figured out how to copy files that are located in multiple subfolders of the main directory, and paste into another folder directory? Also does this transfer method only work for folders on the C drive? I am trying to copy files from our directory that includes multiple subfolders where several files are stored located in Microsoft Sharepoint, to a folder on my C drive.

    Any help would be much appreciated!
  • To post as a guest, your comment is unpublished.
    julien · 2 years ago
    hi do you know how to search also on the subfolder ?
  • To post as a guest, your comment is unpublished.
    technicallyspecific@gmail.com · 2 years ago
    Works great - thank you! However-->>>Can this be adjusted to use a PARTIAL FILE NAME? If so, can you help show how?
    In other words, if file name on the Excel sheet list of filenames is: OW4234TR_J19031.txt (I'd like it to only look at last 5 chars "19031" which is a Julian Date and move a range of files... (anything with a Julian Date of 19092 thru 19120) into the March folder.. The ultimate over-arching task is to locate any files that have Julian dates for March and put those in the Fiscal March Folder "06-Mar" , April into the April folder "07-Apr" and so on...so Fiscal reconciliations by month can then take place.. TIA for any help anyone can offer to expedite this time consuming hunt and picking process. =-)
  • To post as a guest, your comment is unpublished.
    Fer · 2 years ago
    en el codigo que copia ¿como puedo colorear el nombre de la lista que no encuentre?
  • To post as a guest, your comment is unpublished.
    Johnette · 2 years ago
    I cannot get either version to work in Windows 10.


    Argggg
  • To post as a guest, your comment is unpublished.
    Andy · 2 years ago
    Any tips on how to modify the code to add a wide card? I have an archive of hundreds of PDF files that are 10 digit numbers and revision level (XXXXXXXXXX_REVA). I can export a list of file names very easily from our ERP system, but the list is missing the revision and file extension. Is there a way to add wild cards into the program to ignore everything BUT the 10 digit number?
  • To post as a guest, your comment is unpublished.
    PWD · 3 years ago
    Hello,
    how to make this code copy files from subfolders?
  • To post as a guest, your comment is unpublished.
    Gokury · 3 years ago
    Hi Guys,

    How I need to change '' If TypeName(xVal) = "String" And xVal <> "" Then '' to move files based on partial file name.


    Thanks in advance,
    Best regards, P
    • To post as a guest, your comment is unpublished.
      technicallyspecific@gmail.com · 2 years ago
      Did you ever find out HOW to use a PARTIAL FILE NAME? I need that as well...
      In other words, if file name on the Excel sheet list is: OW4234TR_J19031.txt (I'd like it to only look at last 5 chars "19031" which is a Julian Date and move a range of files... anything with a Julian Date of 19031 thru 19075..
      • To post as a guest, your comment is unpublished.
        eric · 2 years ago
        I also would require the partial file name vba modification. Did you ever get a response?
        • To post as a guest, your comment is unpublished.
          Alexandru Matei · 10 months ago
          I am interested in exactly the same solution! Did anyone get the answer?
          I have a P/N list in a column, and I want a piece of code that looks in a parent folder that has several subfolders after files with the name indicated by the list, but only partially, because I don't know the file extension and in many cases for a single P/N in the list, I have several files differentiated by the existence of a suffix that does not always have the same pattern, such as xxxx_1, xxxx_2, xxx (1), xxxx [1], xxxx- (a ), xxxx_ (b) ...., but I need to copy in the destination folder, all the instances of the files that contain in their name the P/N.
          Please help me to not do this job manually for 34078 files that today finds in parent folder and subfolders
  • To post as a guest, your comment is unpublished.
    Sidney · 3 years ago
    Você não tem noção de como me ajudou com esse script... Muito bom!!! Obrigado!!!
  • To post as a guest, your comment is unpublished.
    Robinson · 3 years ago
    Obrigado!!!!
  • To post as a guest, your comment is unpublished.
    Alisson · 3 years ago
    Era exatamente isso que eu precisava!!!

    Muito Obrigado!!!!
  • To post as a guest, your comment is unpublished.
    Raki · 3 years ago
    Hi, In the source folder, I wish to set it as a constant from a cell, for example the path entered in a particular cell, like A1, should be treated as the source folder. How to do this?
  • To post as a guest, your comment is unpublished.
    madhan · 3 years ago
    It is the nice macro.Real helpful for me. but I need some update macro.this used to copy the files from single folder to another folder. we need copy files from folder and subfolder to another folder.