How do I create multiple folders in Excel on a Mac?

Use Microsoft Excel to quickly create multiple folders.

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 "|."

Advertisement

Using a Batch File

Step 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.

Video of the Day

Step 2

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

Step 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.

Advertisement

="md "&FOLDERNAMES

Step 4

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."

@echo off cd "C:\Temp"

Advertisement

Step 5

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:

@echo off cd "c:\Temp" md foldername1 md foldername2 ..

Step 6

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.

Advertisement

Using a Macro

Step 1

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

Step 2

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

Step 3

Copy and paste the following macro in the editor:

Advertisement

Sub MakeFolders()

Dim Rng As Range Dim maxRows, maxCols, r, c As Integer

Set Rng = Selection

maxRows = Rng.Rows.Count maxCols = Rng.Columns.Count

For c = 1 To maxCols r = 1 Do While r <= maxRows If Len(Dir(ActiveWorkbook.Path & "" & Rng(r, c), vbDirectory)) = 0 Then MkDir (ActiveWorkbook.Path & "" & Rng(r, c)) On Error Resume Next End If r = r + 1 Loop Next c

Advertisement

End Sub

Step 4

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.

Step 5

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.

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."

Warning

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.

Advertisement

Video

Postingan terbaru

LIHAT SEMUA