Rename all folders in a root folder

HI Team,

I want help to rename all folders in a root folder with different name using VBA. So that one button click it should happen. In Excel I have all existing folder names in one column and new folder names in another column.  Appreciate your help here.



Top Contributor Asked on September 13, 2017 in VBA: Files & Folders.
Add Comment
1 Answer(s)

Hi Lora,

Here is the vba code to rename all folders in root folder form existing name to new name.  The below code will loop through all folder names and will update new name.

Sub ReName_Folders()
Const sRootFolder As String = "C:\Users\IBM_ADMIN\Desktop\3QWk10\SubBrand Integration\"
Dim Old_FolderName As String, New_FolderName As String
With Sheets("Settings")
For i = 2 To .Range("AE1").End(xlDown).Row
Old_FolderName = sRootFolder & Sheets("Settings").Range("AE" & i)
New_FolderName = sRootFolder & Sheets("Settings").Range("AF" & i)
Name Old_FolderName As New_FolderName
Next i
End With
End Sub

Hope it resolves your requirement




Expert Answered on September 14, 2017.
Add Comment
  • Found this useful?

    Please share using the share button above.

    If you found the answer is best answer for your question, Please mark as 'best answer' by clicking on the right tick mark icon at the left side of the answer.

    Found the answer useful and wants to credit the user, then vote the answer (vote up).

  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.