Excel Guides

Creating a Directory in a Macro in Excel

To create a directory in a macro in Excel, you will first need to create a new module. To do this, go to the Insert menu and click on Module. This will open a new window where you can enter your code.

Next, you will need to declare a variable of type String. This will be used to store the path of the directory you wish to create. To do this, type the following code into your module:

Dim strPath As String

Now, you will need to set the value of this variable to the path of the directory you wish to create. For example, if you wanted to create a directory called "MyDirectory" in the root directory of your C drive, you would set the value of strPath as follows:

strPath = "C:\MyDirectory"

Finally, you will need to use the MkDir function to actually create the directory. The MkDir function takes a single parameter, which is the path of the directory to be created. Therefore, to create our "MyDirectory" folder, we would use the following code:

MkDir strPath

Move beyond 

Excel

Get started with Causal today.
Build models effortlessly, connect them directly to your data, and share them with interactive dashboards and beautiful visuals.