Macro To Move Files to different Folder

AnnieLox

New Member
Joined
Sep 18, 2017
Messages
22
Hello! First time for me to post!! I'm a self taught Macro maker so have patience please.
I am trying to create a macro to move files from one folder to another. I've tried reading and working off other macros I found on here but cant get it to work.

I have an excel sheet with a column of Vendors.

The folder I have will say something like "Bulk 5227834" and there will be up to 70 files with different numbers. I need all of the bulk to move from that folder to the vendor folder. additionally it can either be a PDF or an excel.

I have created a dummy folder to try and do this.

this is the code I have. (It doesn't work) but even if it did, I need the macro to look through the list of vendors, theres too many to write a code line for each.

Code:
Dim d As String, ext, x

    Dim FSO As Object
    Dim FromDir As String
    Dim ToDir As String
    Dim FExtension  As String
    Dim FNames As String
    Dim Files As String
    Dim LR As Long
  
    LR = Sheets("Macro").Range("A" & Rows.Count).End(xlUp).Row
    For RW = 2 To LR

    
    
Dim srcPath As String, destPath As String, srcFile As String
srcPath = "H:\Annie\delete\"
destPath = "H:\Annie\delete2\"
ext = Array("19", "April")
For Each x In ext
    d = Dir(srcPath & x)
        Do While d <> ""
            srcFile = srcPath & d
            FSO.MoveFile , destPath & d
            d = Dir
        Loop
Next
End Sub




any help will be greatly appreciated!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,215,372
Messages
6,124,531
Members
449,169
Latest member
mm424

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top