Question: Through some research and trial and error, I was able to come across this basic VBA that is helping me rename a large list of file attachments. I have been able to rename a few dozen attachments but I run into the run-time error '53: File Not Found.' Is there a way to modify the VBA to skip over the file names that cannot be found?

```
Sub RenameFiles()
Const strPath = "C:\Documents and Settings\User\My Documents\FolderName\"
Dim r As Long
Dim n As Long
n = Cells(Rows.Count, 1).End(xlUp).Row
For r = 2 To n
Name strPath & Cells(r, 1) As strPath & Cells(r, 2)
Next r
End Sub

```

Answer: 
Error handling is disabled with this statement:

```
On Error Resume Next

```

To enable error handling again you have to use this statement:

```
On Error Goto 0

```

It's good practice to disable error handling only for the statements where you realy want to skip the error. On the other side enabling and disabling the error handling may slow doen your code. In that case you can place it arount the loop.

```
On Error Resume Next
For r = 2 To n
  Name strPath & Cells(r, 1) As strPath & Cells(r, 2)
Next r
On Error Goto 0

```
Better than `On Error Resume Next` (in my opinion) is to check for specific/anticipated errors and handle them appropriately. In this case, you can check to see if a filename is valid, and skip the `Name` assignment if it is not valid.

Check to see if it's a valid filename using `Dir()` function:

```
Sub RenameFiles()
Const strPath = "C:\Documents and Settings\User\My Documents\FolderName\"
Dim sFile as String
Dim r As Long
Dim n As Long
n = Cells(Rows.Count, 1).End(xlUp).Row
For r = 2 To n
    sFile = strPath & Cells(r,1)
    If Not Dir(sFile) = vbNullString Then 
        Name sFile As strPath & Cells(r, 2)
    End If
Next r
End Sub

```