We Value Your Privacy

We and our partners use technology such as cookies on our site to personalise content and ads, provide social media features, and analyse our traffic. Click below to consent to the use of this technology across the web. You can change your mind and change your consent choices at anytime by returning to this site.

Update Consent
Loading ...

How to make folders from an excel spreadsheet

Updated July 20, 2017

Excel spreadsheets can help you automate the task of creating multiple folders. One way to generate folders is to create a script using data ranges and the batch command "md." Another method is by using a macro through the MkDir function, a component of Microsoft Excel VBA. This offers flexibility, and it is less time-consuming. Only include proper folder names in your spreadsheet for these techniques to work. Folder names should not contain quotation marks, or any of the characters "\," "/," ":," "*," "?," "<," ">" and "|."

Loading ...
  1. Arrange your folder names in a single column. Click on the column's header and type "FOLDERNAMES" in the name field beside the formula bar.

  2. Add a blank column to the left of the "FOLDERNAMES" column by right-clicking the column header and choosing "Insert."

  3. Highlight the first cell in the blank column. Enter the following text into the formula bar, and copy it to the other blank cells.

  4. \="md "&FOLDERNAMES

  5. Open your plain text editor and create a blank document. Copy and paste the code below at the beginning of the file. Replace "C:\Temp" with the complete path to the directory in which you would like to add folders. For example, to add folders to "Songs" inside your "D" drive, use the path "D:\Songs."

  6. @echo off

  7. cd "C:\Temp"

  8. Return to your Excel workbook. Right-click the header of the column containing the "md" formulas and choose "Copy." Go back to your text editor, and paste the values at the end of the file. Your file should now look something like this:

  9. @echo off

  10. cd "c:\Temp"

  11. md foldername1

  12. md foldername2

  13. ..

  14. Save the file on your Desktop as "CreateFolders.bat." Go to the Desktop, and run the batch file by double-clicking on its icon. Your folders are now ready for use.

  15. Open the Excel workbook. Hold the "Alt" key down and press "F8" to open the Macros window.

  16. Enter "MakeFolders" under "Macro Name," and click the "Create" button. This opens the VBA editor.

  17. Copy and paste the following macro in the editor:

  18. Sub MakeFolders()

  19. Dim Rng As Range

  20. Dim maxRows, maxCols, r, c As Integer

  21. Set Rng = Selection

  22. maxRows = Rng.Rows.Count

  23. maxCols = Rng.Columns.Count

  24. For c = 1 To maxCols

  25. Next c

  26. End Sub

  27. Save your file as a macro-enabled workbook by opening the "File" menu and choosing "Save As." Enter your preferred file name and choose "Excel Macro-Enabled Workbook" beside "Save As File Type." Click the "Save" button.

  28. Highlight the cells containing the folder names. Hold down the "Alt" key and press "F8" to open the Macros window. Double-click on "MakeFolders." The folders are now ready for use.

  29. Tip

    The macro creates folders in the same directory as your active workbook. To create folders in the directory that contains the macro-enabled workbook, replace all instances of "ActiveWorkbook" in the code with "ThisWorkbook."


    If you are using Microsoft Excel 2007, you may not have access to the Macros window and the "Developer" tab by default. To enable this, click the Microsoft Office orb and choose "Excel Options." Click "Popular" in the Category pane, and choose "Show Developer tab in the Ribbon." Click "OK" to save your changes.

Loading ...

Things You'll Need

  • Plain text editor (Notepad, Notepad++ or TextPad)

About the Author

Brian Valle is a technical writer based in South Carolina. Freelancing since 2008, he has written for various blogs and small-business websites, sharing his knowledge about Windows, new applications, life-hacks and computer games. Valle is studying information technology at York Tech College.

Loading ...