using excel to rename filenames?

  • Thread starter Thread starter vmorgan
  • Start date Start date
V

vmorgan

Is it possible to rename a group of filenames using Excel 2000? I have
a column of current filenames and an adjacent column of the desired new
filenames. All files to be changed are in the same folder as the Excel
file.
Thanks!
 
This worked for me--but test it against a folder with not much in it--just in
case:

Option Explicit
Sub testme()

Dim myPath As String
Dim myCell As Range
Dim myRng As Range

myPath = ThisWorkbook.Path & "\"

With ActiveSheet
For Each myCell In .Range("a2", .Cells(.Rows.Count, "A").End(xlUp))
On Error Resume Next
Name myPath & myCell.Value As myPath & myCell.Offset(0, 1).Value
If Err.Number = 0 Then
myCell.Offset(0, 2).Value = "Ok"
Else
myCell.Offset(0, 2).Value = "Failed to rename"
Err.Clear
End If
On Error GoTo 0
Next myCell
End With

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
Back
Top