-
Solved: Creating directories from within excel?
I have a spreadsheet with part numbers in column A and descriptions of those parts in column C. What I would like to do is create a macro that will create Sub-Directories named with the part number then the description after it like this:
-Example Directory Name-
12345 (Part Description)
Inside of a directory called "TESTERS"
"12345" will be in Column A without ""
"Part Description" will be in Column C again no "" and will not have the () that I need added.
Is this something that can be done? Does anyone have a link to some code to get me started? or would it be faster to just create the directories 1 by 1 manually instead of trying to make a macro?
-
Only you know whether a macro is worth it or not.
This starts from sheet1's A2 down to last row with data.
[VBA]Sub MakeSubFolders()
Dim sCell As Range, rootFolder As String
rootFolder = "c:\TESTERS\"
If Dir(rootFolder, vbDirectory) = "" Then
MsgBox "Rootfolder: " & rootFolder & vbLf & "Does Not Exist", vbCritical, "Macro Ending"
Exit Sub
End If
On Error Resume Next
For Each sCell In Sheets("Sheet1").Range("A2", _
Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp))
MkDir rootFolder & sCell.Value & " (" & sCell.Offset(0, 2).Value & ")"
Next sCell
End Sub[/VBA]
-
Thank you Kenneth! that was exactly what I needed!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules