Hi
i have a macro that changes the names of files in a directory i chose. But i have noticed if i want to name two files the same it causes an error........is there something i can incorporate in the coding to highlight this or to create a second file with the same name?
i have a macro that changes the names of files in a directory i chose. But i have noticed if i want to name two files the same it causes an error........is there something i can incorporate in the coding to highlight this or to create a second file with the same name?
Code:
Sub RenameFiles()
Dim myPath As String
myPath = Range("G2")
r = 2
Do Until IsEmpty(Cells(r, 1)) And IsEmpty(Cells(r, 2))
Name myPath & Cells(r, 1).Value As myPath & Cells(r, 2).Value
r = r + 1
Loop
End Sub