VBA Copy in folder and sub folder faster

roykana

Board Regular
Joined
Mar 8, 2018
Messages
113
Office Version
  1. 2010
Platform
  1. Windows
Dear All master,


I want the vba code to copy over entire folders and sub folders very fast.

The vba code below can only be in one folder so if there is, I can modify the vba code to my liking and also I want the process to be very fast.


Thanks

roykana
VBA Code:
Sub copyfiles()

'Updateby royKana

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:", "roykana", 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
 

Some videos you may like

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

roykana

Board Regular
Joined
Mar 8, 2018
Messages
113
Office Version
  1. 2010
Platform
  1. Windows
Dear all master,
can anyone help me for the vba code?

Thanks
Roykana
 

roykana

Board Regular
Joined
Mar 8, 2018
Messages
113
Office Version
  1. 2010
Platform
  1. Windows
Dear all master,
can anyone help me for the vba code?

Thanks
Roykana
 

roykana

Board Regular
Joined
Mar 8, 2018
Messages
113
Office Version
  1. 2010
Platform
  1. Windows
Dear all master,
can anyone help me for the vba code?

Thanks
Roykana
 

roykana

Board Regular
Joined
Mar 8, 2018
Messages
113
Office Version
  1. 2010
Platform
  1. Windows

ADVERTISEMENT

Dear all master,
can anyone help me for the vba code?

Thanks
Roykana
 

roykana

Board Regular
Joined
Mar 8, 2018
Messages
113
Office Version
  1. 2010
Platform
  1. Windows
Dear all master,
can anyone help me for the vba code?

Thanks
Roykana
 

roykana

Board Regular
Joined
Mar 8, 2018
Messages
113
Office Version
  1. 2010
Platform
  1. Windows
Dear all master,

can anyone help and provide a solution for the vba code?


thank you

Roykana
 

Watch MrExcel Video

Forum statistics

Threads
1,122,589
Messages
5,597,053
Members
414,118
Latest member
moversnpackers

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
Top