Script to create list of folders.

First column: First part of the folder name then space

Second column: Second part of the folder name then space

Third column: Third part of the folder name then space

Sub CreateFolders()

    Dim countRows, c As Integer
    Dim ni, surname, initial As String
    
    'count rows here
    countRows = Worksheets("Sheet1").Cells(2, 1).End(xlDown).Row
    For c = 2 To countRows
        ni = Worksheets("Sheet1").Cells(c, 1).Value
        surname = Worksheets("Sheet1").Cells(c, 2).Value
        initial = Worksheets("Sheet1").Cells(c, 3).Value
        If Len(Dir(ActiveWorkbook.Path & "\" & ni & " " & surname & " " & initial, vbDirectory)) = 0 Then
            MkDir (ActiveWorkbook.Path & "\" & ni & " " & surname & " " & initial)
            On Error Resume Next
        End If
    
    Next c
    MsgBox "Folders created"
End Sub

Categorized in:

VBA Excel,

Last Update: May 18, 2024