I have a folder called "Current" which contains a number of pdf files. I want to change it to a new name, but in the same directory, and with the new name being generated from a cell within a worksheet. I have looked at various tutorials and solutions online, but none of them do this particular task. I am a novice without any IT background, but have made a number of complex macros in excel in the past to automate various functions in my day to day work in my office job.
Example; I can use the following Macro which works, but as I will be recreating the folder "Current" and renaming it over and over again using a name generated from within the worksheet, I need the "CurrentRename" part of this macro to be the variable name.
Sub RenameFolder()
Dim oldFolderName As String
Dim newFolderName As String
' Define the full paths for the old and new folders
oldFolderName = "C:\Users\allia\Documents\AW\PDF\Current"
newFolderName = "C:\Users\allia\Documents\AW\PDF\CurrentRename"
' Check if the old folder exists to prevent an error
If Len(Dir(oldFolderName, vbDirectory)) > 0 Then
' Rename the folder
Name oldFolderName As newFolderName
MsgBox "Folder renamed successfully!", vbInformation
Else
MsgBox "Error: The original folder was not found.", vbCritical
End If
End Sub
Any help would be greatly appreciated.
