Sub DoiTenFileName()
Dim fso As Object
Dim OldName As String, NewName As String
Dim a, fo, fi, fin As String
Dim i As Integer
Dim ws As Worksheet
Set fso = CreateObject("Scripting.FileSystemObject")
a = ActiveWorkbook.Name
If Not fso.FolderExists(Workbooks(a).Sheets(1).Range("B1").Value) Then
MsgBox "Folder Error"
Else
fo = Workbooks(a).Sheets(1).Range("B1").Value
i = 1
Do
i = i + 1
fi = Workbooks(a).Sheets(1).Cells(i, 3).Value
fin = Workbooks(a).Sheets(1).Cells(i, 4).Value
If fi = "" Then Exit Do Else
If fin = "" Then
Else
OldName = fo & "\" & fi
NewName = fo & "\" & fin
If fso.FileExists(OldName) Then fso.MoveFile OldName, NewName
End If
Loop
End If
Set fso = Nothing
MsgBox "DOI TEN FILE XONG!"
End Sub