Copy files from a source to destination by reading Path from Excel.

fareed

New Member
Joined
Aug 10, 2013
Messages
2
Dear All,

I would like to copy files from a source to destination by using Excel Macro/Batch file.
I have saved the path of the files of source and destination as columns in Excel sheet.
I would like to know how to write VBA macro to copy files by reading the source/destination path from columns.

Thanks in advance.
Regards,

Fareed.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hello

Welcome to MrExcel.

If column A has the source files (path and filename and extension), and column B as the target files (path and filename and extension), then this will work:

Code:
For Each r In Columns(1).SpecialCells(2,2)
   If Len(Dir(Trim(r.Value))) Then FileCopy r.Value, r.Offset(,1).Value
Next
 
Upvote 0
Hello

Welcome to MrExcel.

If column A has the source files (path and filename and extension), and column B as the target files (path and filename and extension), then this will work:

Code:
For Each r In Columns(1).SpecialCells(2,2)
   If Len(Dir(Trim(r.Value))) Then FileCopy r.Value, r.Offset(,1).Value
Next

Thanks for the prompt response. I will try it out once I am at the console.

Just to clarify : Column A has Source path only ( The actual folder has multiple files and all of them need to be copied).
Column B has destination path ONLY.

Will the above solution work in such a scenario ?


Thanks once again.
Fareed
 
Upvote 0
Thanks for the prompt response. I will try it out once I am at the console.

Just to clarify : Column A has Source path only ( The actual folder has multiple files and all of them need to be copied).
Column B has destination path ONLY.

Will the above solution work in such a scenario ?


Thanks once again.
Fareed

No. You will need to use the Dir( ) function to loop through the files in the directory in column A.
 
Upvote 0

Forum statistics

Threads
1,216,073
Messages
6,128,646
Members
449,462
Latest member
Chislobog

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