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

  • Thread starter Thread starter sseyerle
  • Start date Start date
S

sseyerle

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?
 
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
ResumeHere:
Next myC
Exit Sub
FolderExists:
Resume ResumeHere
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top