Copying Files From Folder to Another

hetherton

New Member
Joined
May 24, 2022
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
I have a worksheet as such Col A File Name Col B File Extension(Which doesnt change) Col C File Source Path( changes)

I want to copy the files in the list to a folder. The destination folder is the same for all

This is what I have so far but extremly new to VBA so could be completely wrong

VBA Code:
Sub sbCopyingAFile()

'Variables
Dim FSO
Dim sFile As String
Dim sSFolder As Range
Dim sDFolder As Range

'File name to copy
Set sFile = Application.InputBox("Please Select File Names:", "ww", ActiveWindow.RangeSelection.Address, , , , , 8)
If sFile Is Nothing Then Exit Sub

'Source Path
Set sSFolder = Application.InputBox("Please Select Folder Paths:", "ww", ActiveWindow.RangeSelection.Address, , , , , 8)
If sFile Is Nothing Then Exit Sub



'Destination Path
sDFolder = "C:\Users\MEStudent\Documents\Test Folder"


Set FSO = CreateObject("Scripting.FileSystemObject")


If Not FSO.FileExists(sSFolder & sFile) Then
    MsgBox "Specified File Not Found", vbInformation, "Not Found"
    

ElseIf Not FSO.FileExists(sDFolder & sFile) Then
    FSO.CopyFile (sSFolder & sFile), sDFolder, True
    MsgBox "Specified File Copied Successfully", vbInformation, "Done!"
Else
    MsgBox "Specified File Already Exists In The Destination Folder", vbExclamation, "File Already Exists"
End If

End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,214,822
Messages
6,121,765
Members
449,049
Latest member
greyangel23

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