I have a macro that renames files based on the contents of two ranges.
i.e 'Column A' contains the original name and 'Column E' will be the new name.
When I run the macro it crashes if I haven't renamed an item in the 'Column E'.
Is there a way to skip a cell if it is the same in both ranges?
Thanks
i.e 'Column A' contains the original name and 'Column E' will be the new name.
When I run the macro it crashes if I haven't renamed an item in the 'Column E'.
Is there a way to skip a cell if it is the same in both ranges?
Thanks
VBA Code:
Sub RenameFiles()
Dim myPath As String
myPath = Sheet1.[address1]
r = 2
Do Until IsEmpty(Cells(r, 1)) And IsEmpty(Cells(r, 5))
Name myPath & Cells(r, 1).Value As myPath & Cells(r, 5).Value
r = r + 1
Loop
MsgBox "Successful"
End Sub