MACRO - currently creates folders from list, need to add workbook to each folder

kdowning

New Member
Joined
Nov 21, 2013
Messages
4
Hello,

I have a current MACRO I use when ran prompts the user to select a location to save all folders. Once the user selects a location and hits "Ok" the MACRO creates a new folder using a list in excel (E26:E75) that the user can modify so they don't have to manually create folders and rename them.

I need the MACRO to also create and save an excel work book in each folder with the same name as the newly created folder. On a side note, in the same workbook that the users enter the list of folders they want created there is another worksheet/tab that has the a templated worksheet that needs to be saved as a workbook in each newly created folder. Currently, I am asking for help putting an empty workbook in each folder, once this is done each user can go in to each folder and newly created workbook and copy/past the templated worksheet and update as necessary.

Big picture, creating a folder for each "step" with an applicable "workpaper" in each folder. Each "workpaper" should have the same basic template format and stock information but some cells/information will change based on "steps" for each "workpaper".

Any help or guidance would be appreciated, thanks.

Current MACRO:
CODE#

Sub Create_Folders()

'Macro to create folders from list in excel

Dim R As Range
Dim RootFolder As String
RootFolder = GetFolder() 'Uses GetFolder module to prompt user to select location for folders

For Each R In Range("E26:E75") 'Targeted Cells from which to create folders based on
If Len(R.Text) > 0 Then
On Error Resume Next
MkDir RootFolder & "" & R.Text
On Error GoTo 0
End If
Next R

End Sub


Function GetFolder() As String

'Macro to prompt users to select location for files or folders

Dim fldr As FileDialog
Dim sItem As String
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
With fldr
.Title = "Select a Folder"
.AllowMultiSelect = False
.InitialFileName = Application.DefaultFilePath
If .Show <> -1 Then GoTo NextCode
sItem = .SelectedItems(1)
End With
NextCode:
GetFolder = sItem
Set fldr = Nothing

End Function
 
Last edited:

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top