Luis Diaz
asked on
VBA Excel: rename files
Hello experts,
I have the following procedure which allows me to rename files.
I would like to add a msgbox vbyes &Â vbyes at the beginning of the procedure with the following message:
"Before running this procedure, please check that old_files_names are reported in column A and new_files_names are reported in column B. If so, please click on Yes else click on No and run List Files procedure in order to get files to rename."
If you have questions, please contact me.
Regards,
I have the following procedure which allows me to rename files.
Sub Rename_Files()
'Updateby20141124
Dim xDir As String
Dim xFile As String
Dim xRow As Long
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
If .Show = -1 Then
xDir = .SelectedItems(1)
xFile = Dir(xDir & Application.PathSeparator & "*")
Do Until xFile = ""
xRow = 0
On Error Resume Next
xRow = Application.Match(xFile, Range("A:A"), 0)
If xRow > 0 Then
Name xDir & Application.PathSeparator & xFile As _
xDir & Application.PathSeparator & Cells(xRow, "B").Value
End If
xFile = Dir
Loop
End If
End With
End Sub
I would like to add a msgbox vbyes &Â vbyes at the beginning of the procedure with the following message:
"Before running this procedure, please check that old_files_names are reported in column A and new_files_names are reported in column B. If so, please click on Yes else click on No and run List Files procedure in order to get files to rename."
If you have questions, please contact me.
Regards,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You're welcome! Glad it worked as desired.
Thanks for the feedback.
Thanks for the feedback.
ASKER
Thank you very much for your prompt answer!