Sub Move_File()
Dim strFile As String, strNewFile As String
Const strSourcePath As String = "C:\Temp\"
Const strDestinationPath As String = "C:\Temp2\"
strNewFile = "Test " & Format(Sheets("Sheet1").Range("A1").Value, "dd-mm-yyyy")
If Dir$(strDestinationPath & strNewFile) <> "" Then
MsgBox "There is already an existing file named " & vbLf & strDestinationPath & strNewFile, _
vbExclamation, "Dated File Name Exists"
Exit Sub
End If
strFile = Dir$(strSourcePath & "Test*")
If strFile <> "" Then
Name (strSourcePath & strFile) As (strDestinationPath & strNewFile)
MsgBox "Old file: " & strSourcePath & strFile & vbLf & vbLf & _
"New file: " & strSourcePath & strNewFile, , "File Moved"
Else
MsgBox "No test file found. ", , "File Not Found"
End If
End Sub
Bookmarks