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
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