Hello,
I'm using a macro to copy from one location to another using the below. I'm wondering how I can amend this to MOVE the files instead of copy. Or better yet, is there a way to add a message box to ask the user if they want to move or copy and have it work from there?
I'm sure it's something simple that I'm missing but any help is appreciated!
I'm using a macro to copy from one location to another using the below. I'm wondering how I can amend this to MOVE the files instead of copy. Or better yet, is there a way to add a message box to ask the user if they want to move or copy and have it work from there?
I'm sure it's something simple that I'm missing but any help is appreciated!
Code:
Dim NewName As String
Sub Copyfilefromto()
Dim mycheck As VbMsgBoxResult
mycheck = MsgBox("Confirm that you'd like to start the file mover. The more files to move, the longer this will take.", vbYesNo)
If mycheck = vbNo Then
Exit Sub
End If
Dim a As Long, x As Long
Dim FilePath As String
Dim FileName As String
Dim ErrCount As Long
ErrCount = 1
x = Worksheets("Query").Cells(Rows.Count, 3).End(xlUp).Row
For a = 4 To x
FilePath = Worksheets("Query").Cells(a, 4)
FileName = Worksheets("Query").Cells(a, 3)
On Error GoTo ErrorHandler
Call GetFileType(FileName, FilePath, a)
FileCopy Worksheets("Query").Cells(a, 4) & Worksheets("Query").Cells(a, 3), Worksheets("Query").Cells(a, 1) & NewName
Next a
MsgBox ("Process Complete. Please review ErrMsgs Sheet for failures.")
Cells(2, 5).Value = x - 3
Exit Sub
ErrorHandler:
Worksheets("ErrMsgs").Activate
Cells(ErrCount, 1).Value = FileName
Cells(ErrCount, 2).Value = Err.Description
Worksheets("Query").Activate
ErrCount = ErrCount + 1
Resume Next
End Sub