Hi, I am looking for some help to adjust this VBA. I use this to rename files within a folder, but it only works for the files listed in the main folder. How can I modify this code to rename files that are located in the subfolders too? Thanks in advance
[FONT="]Sub rename_folder()[/FONT]
[FONT="]Const FILEPATH As String = "C:\test"[/FONT]
[FONT="]Dim strfile As String[/FONT]
[FONT="]Dim filenum As String[/FONT]
[FONT="]strfile = Dir(FILEPATH)[/FONT]
[FONT="] [/FONT]
[FONT="]Dim old_name, new_name As String[/FONT]
[FONT="]For i = 2 To Sheets(1).Range("a1").End(xlDown).Row[/FONT]
[FONT="] [/FONT]
[FONT="]strOldDirName = FILEPATH & Sheets(1).Cells(i, 1).Value[/FONT]
[FONT="]strNewDirName = FILEPATH & Sheets(1).Cells(i, 3).Value[/FONT]
[FONT="]Name strOldDirName As strNewDirName[/FONT]
[FONT="] [/FONT]
[FONT="]Next i[/FONT]
[FONT="]End Sub[/FONT]
[FONT="] [/FONT]
[FONT="]Sub rename_folder()[/FONT]
[FONT="]Const FILEPATH As String = "C:\test"[/FONT]
[FONT="]Dim strfile As String[/FONT]
[FONT="]Dim filenum As String[/FONT]
[FONT="]strfile = Dir(FILEPATH)[/FONT]
[FONT="] [/FONT]
[FONT="]Dim old_name, new_name As String[/FONT]
[FONT="]For i = 2 To Sheets(1).Range("a1").End(xlDown).Row[/FONT]
[FONT="] [/FONT]
[FONT="]strOldDirName = FILEPATH & Sheets(1).Cells(i, 1).Value[/FONT]
[FONT="]strNewDirName = FILEPATH & Sheets(1).Cells(i, 3).Value[/FONT]
[FONT="]Name strOldDirName As strNewDirName[/FONT]
[FONT="] [/FONT]
[FONT="]Next i[/FONT]
[FONT="]End Sub[/FONT]
[FONT="] [/FONT]