Create Folders Based on Cell Values using Macros (VBA) in Excel 365!!
Tags: vbamacros
Published: 2021-02-24 11:43:24

---
title: Create Folders Based on Cell Values using Macros (VBA) in Excel 365!!
published: true
date: 2021-02-24 09:13:59 UTC
tags: VBAMacros
canonical_url: https://geekexcel.com/create-folders-based-on-cell-values-using-macros-vba-in-excel-365/
---

In this post, we are going to explore how to **[create folders based on cell values](https://geekexcel.com/how-to-create-folders-based-on-cell-values-in-excel-office-365/) using Macros** in Excel Office 365. Macros and [VBA](https://geekexcel.com/excel-office-365-vba-overview-definition-and-examples/) are really easy to use and provide a quick way to achieve any kind of task. Let’s see them below!!
## Create Folders Based on Cell Values:

Let’s see an example to know how it works.

- For instance, you can see some values in the range **B1:B6** in the below screenshot.
- We are going to create folders based on those cells in the current workbook directory.

![Example input range](https://geekexcel.com/wp-content/uploads/2021/02/EXCEL_VEZ6nMe0Bg.png)<figcaption id="caption-attachment-22102">Example input range</figcaption>

- On the **Developer Tab, select** the **Visual Basic** option under the **Code** section.

![Select Visual Basic option](https://geekexcel.com/wp-content/uploads/2020/09/Select-Visual-Basic-option-4.png)<figcaption id="caption-attachment-14755">Select the Visual Basic option</figcaption>

- Then you need to copy and paste the code given below.

VBA code to create folders using Macros

Sub MakeFolders()

Dim dirName as string

on error resume next

For i=1 to 6

dirName=cells(1,i).values

mkdir (ActiveWorkbook.Path & “\” & dirName)

next i

End Sub

- You need to **save the code** by selecting it. Then **close** the **window.**

![Save the code](https://geekexcel.com/wp-content/uploads/2021/02/EXCEL_I2KSnI3wPX.png)<figcaption id="caption-attachment-22103">Save the code</figcaption>

- You have to open the sheet containing the data. On the **Developer Tab, choose** the **Macros option** in the **Code** section.

![Choose the Macros option](https://geekexcel.com/wp-content/uploads/2020/09/Choose-the-Macros-option-2.png)<figcaption id="caption-attachment-14747">Choose the Macros option</figcaption>

- You need to make sure that your macro is selected and **click** the **Run** button.

![Click the Run button](https://geekexcel.com/wp-content/uploads/2021/02/EXCEL_X62MPPxKQ4.png)<figcaption id="caption-attachment-22104">Click the Run button</figcaption>

- At last, the folders have been created under the current spreadsheet active directory.

![Output](https://geekexcel.com/wp-content/uploads/2021/02/wC6sl35QDA.png)<figcaption id="caption-attachment-22105">Output</figcaption>

## Closure:

In this post, we have learned the steps to **create folders based on cell values using Macros** in Excel Office 365. You just follow the steps to create your folders. Kindly, give your **suggestions/feedback** in the below comment section. Thanks for visiting **[Geek Excel.](https://geekexcel.com/)** Keep Learning!

#### Keep Reading:

- **[Merge Multiple Cells into One Cell using Macros (VBA) in Excel 365!!](https://geekexcel.com/merge-multiple-cells-into-one-cell-using-macros-vba-in-excel-365/)**
- **[How to Copy a Cell to Clipboard using Macros (VBA) in Excel 365?](https://geekexcel.com/how-to-copy-a-cell-to-clipboard-using-macros-vba-in-excel-365/)**
- **[Convert Formulas into Values using Macros (VBA) in Excel 365!!](https://geekexcel.com/convert-formulas-into-values-using-macros-vba-in-excel-365/)**
- **[Create the Data Entry Form using Macros (VBA) in Excel Office 365!](https://geekexcel.com/create-the-data-entry-form-using-macros-vba-in-excel-office-365/)**