ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   create multiple folders and name them by cells in a column excel vba (https://www.excelbanter.com/excel-programming/421191-create-multiple-folders-name-them-cells-column-excel-vba.html)

sseyerle

create multiple folders and name them by cells in a column excel vba
 
I have a workbook with student information. I want to grab each last
name to name folders where thier files can be stored. there are about
1000 names, some are repeats (ex adams, mike and adams, jeff).
can this be done?

Bernie Deitrick

create multiple folders and name them by cells in a column excel vba
 
sseyerle,

I would use full names, just for clarity - but, in any case, paste this code
into a regular codemodule of a new workbook, save the workbook into the
parent folder where you want all the new folders, select the cells with your
desired folder names and run this macro.

HTH,
Bernie
MS Excel MVP

Sub MakeFolders()
Dim myC As Range
On Error GoTo FolderExists
For Each myC In Selection
MkDir ThisWorkbook.Path & "\" & myC.Value
ResumeHe
Next myC
Exit Sub
FolderExists:
Resume ResumeHere
End Sub


"sseyerle" wrote in message
...
I have a workbook with student information. I want to grab each last
name to name folders where thier files can be stored. there are about
1000 names, some are repeats (ex adams, mike and adams, jeff).
can this be done?





All times are GMT +1. The time now is 06:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com