Sub CopyFolderAndRename()
Dim fPath As String, rootPath As String, folderName As String, r As Range
rootPath = "C:\Users\dfranklin\desktop\" 'File address without file name
folderName = "New folder" 'The name of folder to copy
Set oFSO = CreateObject("Scripting.FileSystemObject")
If oFSO.FolderExists(rootPath & folderName) = False Then
MsgBox "Path not found.", vbExclamation, "Error"
Else
Sheets("2021 Proposals").Activate
On Error GoTo errhandler
Set r = Application.InputBox("Select a cell in a row after which you'd like to name the folder you're creating.", "Folder Name Choice", Type:=8)
If r.Rows.Count = 1 Then
fPath = rootPath & Range("A" & r.Row) & "_" & Range("B" & r.Row) & "_" & Range("C" & r.Row) & "_" & Range("D" & r.Row)
'Copy and paste the following lines and edit "/" to whatever character that file names can't contain
'==============================
If InStr(fPath, "/") > 0 Then '<= "/" to edit
fPath = Replace(fPath, "/", " ") '<= "/" to edit
End If
'==============================
If oFSO.FolderExists(fPath) = True Then
MsgBox "There already exists a folder with the same name.", vbExclamation, "Error"
Exit Sub
End If
On Error GoTo errhandler2
oFSO.CopyFolder rootPath & folderName, fPath
Range("A" & r.Row).Resize(, 7).Interior.ColorIndex = 15
MsgBox "Folder has been created : " & vbCrLf & vbCrLf & fPath, vbInformation, "Notification"
Debug.Print fPath 'In case you lose sight of the created folder
Else
MsgBox "Please select a cell in one row.", vbExclamation, "Error"
End If
End If
Exit Sub
errhandler: 'Do nothing if selection is canceled
errhandler2: MsgBox "The folder name contains characters that can't be in file names.", vbExclamation, "Error"
End Sub