• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Make Folder Macro - specify folder

jassybun

Member
The code below creates folders in the right place, however, I also need to add a few more steps and I am not sure how to go about it.

Based off the excel sheet, a folder needs to be created and sorted into the month folder indicated in the name in the cell value in Column R: Lastname Firstname m.d.yyyy Location.

For example:

"Jones Samantha 1.2.2019 Chicago" is the text in the R column should create a folder in the already made January folder if it doesn't already exist.

There is one exception though: if Column J indicates any of two specific words, as an example: "ReviewItem1" or "ReviewItem2", then it instead goes into a folder named "Review", and then into the correct month folder.

If possible I would like to know what new folders were created that did not already exist in a separate excel worksheet.

So the folders looks like:

Review
January
February
etc.

inside the Review folder:
January
February
etc.

Screen Shot 2018-12-20 at 13.32.42.png

Code:
Sub MakeFolders()
Dim Rng As Range
Dim maxRows, maxCols, r, c As Integer
Set Rng = Selection
maxRows = Rng.Rows.Count
maxCols = Rng.Columns.Count
For c = 1 To maxCols
r = 1
Do While r <= maxRows
If Len(Dir(ActiveWorkbook.Path & "\" & Rng(r, c), vbDirectory)) = 0 Then
MkDir (ActiveWorkbook.Path & "\" & Rng(r, c))
On Error Resume Next
End If
r = r + 1
Loop
Next c
End Sub
 
Last edited:
I'd recommend uploading sample of your workbook set up (with desensitized names etc).

And snapshot of how the resulting folder structure looks like.
 
Back
Top