Hello all,
Could you please help telling why my code access file number 10 before number 02?
First it worked but after my IT change some version of office or windows, it is not working now. i have a bunch of files which name start from xxx01 to xxx200.
When the code rename file number 01 then it go to nuber 10 instead of number 02. I have no idea why it is happening.
Thank you very much
Could you please help telling why my code access file number 10 before number 02?
Code:
Sub PDFRename()
Dim MyPath
Dim MyFile As File
Dim NUM As String
Dim FSO As Object
Dim Lrow As Long
Dim x As Long
Lrow = ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row
x = 4
Application.EnableCancelKey = xlInterrupt
Set FSO = CreateObject("Scripting.FileSystemObject")
Set MyPath = FSO.GetFolder("C:\Users\Vanda\DesktopRename File\")
For Each MyFile In MyPath.Files
NUM = ActiveSheet.Cells(x, 2).Text
MyFile.Name = NUM & ".pdf"
'MyFile.Move NexPath
x = x + 1
If x = Lrow Then Exit Sub
Next
End Sub
When the code rename file number 01 then it go to nuber 10 instead of number 02. I have no idea why it is happening.
Thank you very much