Macro to Create New Folder using User Defiend Pathway

lwebbie

New Member
Joined
Feb 28, 2017
Messages
24
I have a code that creates a new folder to a specific pathway but the issue is now we need to be able to allow the user to define the pathway (location changes weekly and by user). I can't figure out how to get it to allow me to let the user pick where to create the folder.


Current Code:
Sub FolderCreation
FolderName = Format(Date, "yyyy-mm-dd")
MkDir "W:\WAC\Regional\WA_OnTap\Team\XH Customer Letters\Sent Letters" & FolderName
End Sub

Thanks!
 

Some videos you may like

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
16,868
Office Version
2010
Platform
Windows
Code:
Sub FolderCreation()
Dim fPath As String
FolderName = Format(Date, "yyyy-mm-dd")
fPath = InputBox("Enter the path to the new folder")
If fPath = "" Then Exit Sub
MkDir fPath & FolderName
End Sub
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
41,305
Office Version
365
Platform
Windows
Another option
Code:
Sub MakeNewFolder()
   Dim Fldr As String
   Dim FolderName As String
   FolderName = format(Date, "yyyy-mm-dd")
   With Application.FileDialog(4)
      .AllowMultiSelect = False
      If .Show <> -1 Then Exit Sub
      Fldr = .SelectedItems(1)
   End With
   MkDir Fldr & "\" & FolderName
End Sub
This lets the user browse for the folder they want the new folder placed in
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
41,305
Office Version
365
Platform
Windows
Glad we could help & thanks for the feedback
 

Watch MrExcel Video

Forum statistics

Threads
1,100,209
Messages
5,473,170
Members
406,849
Latest member
gustavor0

This Week's Hot Topics

Top