No connection
...create folders then rename the folders to different folder names. The folder list is likely to be large (500 different folder names plus).
So you want to make a set of new folders within a pre-existing folder?
If so, the following code might help
Code:
Sub makeFolders()
mainfolder = "c:\testfolder\"
For Each cel In ActiveSheet.Range("A1", Cells(Rows.Count, "A").End(xlUp))
MkDir mainfolder & cel.Value
Next
End Sub
If you set mainfolder to the location you want all your new folders to be created and create a sheet where column A contains a list of the folder names, then this will create those folders.
There's no error checking, so if there are any characters that aren't allowed in file names, it'll fall over.
Test it in a testfolder like mine to make sure it does what you want.
This didn't work for me. I named a folder "testfolder" on my desktop, then I added test spreadsheet on the desktop with a list of names in A. I tried to run the macro to create folders in the testfolder with all the names, but I get a path not found error or a run time error. What's that about?
Checked through more thoroughly and found one or two errors...space in folder name ie 'test folder' and duplicate names in list. Code is sensitive...is there any error checking code that can be included? and can this code be made to create folders from more than one list of names at a time?
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.