Need a macro to move files from Source Folder to Destination Folder, based on Table

seenai

Board Regular
Joined
Mar 31, 2013
Messages
54
Hi,

I have a table with below data :
1) Source File name with Folder Path and
2) Destination Folder with File Name.

I need to move these files into different folders.
It would be great if there can be a macro to help.

Eg :
Move Files.jpg
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
try this:
VBA Code:
Sub movefile()
Dim src As String
Dim dst As String

lastrow = Cells(Rows.Count, "A").End(xlUp).Row
inarr = Range(Cells(1, 1), Cells(lastrow, 4))
For i = 3 To lastrow
'You can change the path and file name
    src = inarr(i, 2)
    dst = inarr(i, 3)
     Name src As dst
    
Next i
End Sub
 
Upvote 0
Cross posted move files from Source Folder to Destination Folder, based on file name & Path

While we do allow Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
Cross posted move files from Source Folder to Destination Folder, based on file name & Path

While we do allow Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
Sure. Thanks.
 
Upvote 0
try this:
VBA Code:
Sub movefile()
Dim src As String
Dim dst As String

lastrow = Cells(Rows.Count, "A").End(xlUp).Row
inarr = Range(Cells(1, 1), Cells(lastrow, 4))
For i = 3 To lastrow
'You can change the path and file name
    src = inarr(i, 2)
    dst = inarr(i, 3)
     Name src As dst
  
Next i
End Sub

The code worked very well. Thank you very much for the timely support.
 
Upvote 0

Forum statistics

Threads
1,214,516
Messages
6,119,978
Members
448,934
Latest member
audette89

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