Reputation: 11
How could I change the path for the folder and its subfolders created on the code below based on a cell value?
-Create a main folder representing month/year Ex. "0820"
-Create sub folders for all defined tasks for this month and save them in "0820" -When it is a new month I would like to just run the macro and have next month's folder created "0920" and the new monthly tasks sub folders will be created under this folder structure.
I do not know how to code the path to saved sub folders to based on cell value, instead of a hard defined path that I would have to modify every month or manually transfer new folders.
Here is what I have to create the task folders, but this does not allow for a flexible sub folder.
Sub CreatePMIDFolders() 'Excel VBA to make a folder.
Dim i As Integer
On Error Resume Next
For i = 2 To 1000
MkDir "C:\PM_CM_Cdrive\PM_CM Uploads_Cdrive\" & Range("M" & i)
Next i
End Sub
Thanks in advance
Upvotes: 1
Views: 110
Reputation: 11978
Try:
MkDir "C:\PM_CM_Cdrive\PM_CM Uploads_Cdrive\" & Format(Month(Date), "00") & Right(Year(Date), 2)
This will autoupdate itself when a new month comes in.
Upvotes: 2