How to create folders and subfolders from a list in Excel

One of the most useful tools that we will get is Microsoft Excel, which offers the possibility of programming functions that allow us to perform actions that we could not before. Mainly, it allows us to perform repetitive actions that we can automate to save time and minimize execution errors.

In this article we will teach you how to create folders and subfolders from a list in Excel . We will do this using what Excel macros are to just press a button and do what we want to do. Likewise, we will explain all the guidelines that you must consider to be able to run the macro without any error message.

Index

  • Using the options on the Developer tab
  • Creating the folderCreate () macro
  • Considerations to take about the macro
  • Creating folders from a list in Excel

Using the options on the Developer tab

In order to make a macro easily, we need to have the Developer tab available on the toolbar. In case you do not have it visible, you just have to right click on any place on the taskbar and then select “Customize Ribbon” .

A pop-up window will appear and in the box on the right we will enable the option “Developer” or “Developer” and then we will click “OK” . From this moment we must verify if the tab we need has been added.

Creating the folderCreate () macro

Now, to create the macro that we will need to create the folders from a list we will only have to follow the steps below:

  • In the “Programmer”tab we will click on “Visual Basic” .
  • Immediately a pop-up window will appear where we will have to go to the top menu and click on the “Insert”tab .
  • Then, in the drop-down menu we will select “Module”and then we will paste the following code:

Sub FoldersCreate ()

path = InputBox (“Enter the path where you want to create the folders”)

cell = InputBox (“First cell”)

Range (cell) .Select

Do While ActiveCell.Value <> “”

MkDir (path & “/” & ActiveCell.Value)

ActiveCell.Offset (1, 0) .Select

Loop

End Sub

  • The next thing will be to close the “Visual Basic”window to finish the macro. And ready! The macro will be available to create folders in your Excel sheet.

As you can see, creating macros is a simple process as long as you have the correct logic when programming it . However, having not properly designed the code, we must know how it works.

Considerations to take about the macro

Before using this macro that we just created, it is important to know how its logic works so that we can use it without errors or problems. Before executing the macro you should consider that:

  • The macro creates folders only from the same column. In case of having the information in rows, you must transpose it to columns.
  • The column must have all its cells with the names of the folders you want to create. An empty cell will automatically terminate the macro process.
  • When placing the path where you want the folders to be created, it should not have folders that matchthe name of any of the folders to be created. This can lead to a runtime error.

Creating folders from a list in Excel

Once the macro has been created and its operation understood, we can proceed to use it. For this, you just have to follow the steps below:

  • We will go to the “Developer”tab and select “Macros” .
  • A pop-up window will appear where the macro “FoldersCrear” should appear, we will select it and press “Execute”.
  • Next, a window will appear where we will have to enter the path where we want the folders to be created. We will enter the path, for example, “C: \ Users \ Desktop \”to create them on the desktop. We will press “Accept”.
  • Afterwards, we will have another window that will ask us in which cell the list begins or which is the first cell. We will write, for example, A5, because it is the cell where the list begins. We will press “Accept”.
  • And ready! If you clicked “OK” and there was no error message, all you have to do ischeck the path to see the folders created.

With Excel the process of creating folders from a list of names is something that we can make very easy. Likewise, applying conditional formatting to our program can also improve its appearance . On the other hand, you can also lock and fix cells so that their information is not edited or deleted.

I hope this macro is of great help to you, don’t forget to share and see you next time .

 

 

by Abdullah Sam
I’m a teacher, researcher and writer. I write about study subjects to improve the learning of college and university students. I write top Quality study notes Mostly, Tech, Games, Education, And Solutions/Tips and Tricks. I am a person who helps students to acquire knowledge, competence or virtue.

Leave a Comment