VBA使用頻度の高いコード(10):フォルダ一括作成
フォルダ一括作成
フォルダ内の特定ファイル読出し用コード
シート上の名称をもとに一括でフォルダ作るコードです
===============================
Sub フォルダ一括作成()
Dim Path As String '作成予定フォルダの上位パス
Path = ThisWorkbook.Path
Dim i As Long 'フォルダ数カウンタ
For i = 10 To Range("N10").End(xlDown).Row
Dim FolderName As String '作成するフォルダ名
FolderName = Cells(i, 任意の列番号).Value
Dim NewDirPath As String '作成予定のフォルダパス
NewDirPath = Path & "\" & FolderName
'作成予定フォルダと同名のフォルダの存在有無を確認し、存在しない場合フォルダ作成
If Dir(NewDirPath, vbDirectory) = "" Then
MkDir Path & "\" & FolderName
Else
End If
Next i
MsgBox "終了しました。"
End Sub
===============================