Copying Folders from one location to another based on a excel spreadsheet

Philip L

New Member
Joined
Nov 2, 2017
Messages
1
Hi I was wondering if I can get some help, we have received a load of data in folders based on cases, we know from each case via a lookup which case belongs to which individual.

[TABLE="width: 404"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]Existing Folder[/TD]
[TD]New Folder[/TD]
[/TR]
[TR]
[TD]h:\ESCC\OB\KYB\3923[/TD]
[TD]H:\ESCC\Donna Waddington 051970[/TD]
[/TR]
[TR]
[TD]h:\ESCC\OW\KYB\3854[/TD]
[TD]H:\ESCC\Debra Cheesman 02061981[/TD]
[/TR]
[TR]
[TD]h:\ESCC\OW\KYB\4143[/TD]
[TD]H:\ESCC\Colleen Jones 11091981[/TD]
[/TR]
[TR]
[TD]h:\ESCC\OB\NC1\3988[/TD]
[TD]H:\ESCC\Sarah Jacobs Jones 041969[/TD]
[/TR]
[TR]
[TD]h:\ESCC\OM\CMH\3608[/TD]
[TD]H:\ESCC\Hannah AL-Moosavi 051967
[/TD]
[/TR]
</tbody>[/TABLE]

I need to copy the data from the existing folder to a new folder based on the file paths in the excel spreadsheet.

I can use the following script to move one file but this doesn't work for multiple folders..

Sub Copy_Folder()
'This example copy all files and subfolders from FromPath to ToPath.
'Note: If ToPath already exist it will overwrite existing files in this folder
'if ToPath not exist it will be made for you.

Dim FSO As Object
Dim FromPath As String
Dim ToPath As String

FromPath = "C:\Users\Ron\Data" '<< Change
ToPath = "C:\Users\Ron\Test" '<< Change

'If you want to create a backup of your folder every time you run this macro
'you can create a unique folder with a Date/Time stamp.
'ToPath = "C:\Users\Ron" & Format(Now, "yyyy-mm-dd h-mm-ss")

If Right(FromPath, 1) = "" Then
FromPath = Left(FromPath, Len(FromPath) - 1)
End If

If Right(ToPath, 1) = "" Then
ToPath = Left(ToPath, Len(ToPath) - 1)
End If

Set FSO = CreateObject("scripting.filesystemobject")

If FSO.FolderExists(FromPath) = False Then
MsgBox FromPath & " doesn't exist"
Exit Sub
End If

FSO.CopyFolder Source:=FromPath, Destination:=ToPath
MsgBox "You can find the files and subfolders from " & FromPath & " in " & ToPath

End SubCan I get some help?
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,223,902
Messages
6,175,278
Members
452,629
Latest member
SahilPolekar

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