Excel VBA Tutorial on How to Create a Folder

Excel VBA Tutorial on How to Create a Folder thumbnail
You can save time using VBA to replace keystrokes

Visual Basic for Applications (VBA) is a programming language that can be used to customize Excel worksheets to fit your business and personal needs. For example, you may find that you are constantly creating new folders to store documents. Instead of navigating through a series of lengthy menus to create a new folder, you can create a small piece of VBA code to do the task for you---saving time and eliminating repetitive keystrokes.

Instructions

    • 1

      Determine the path of the folder you want to create, including the drive letter. For example, you may want to create a folder called MyNewFolder at the root of your drive, so the full path would be "C:\MyNewFolder\"

    • 2

      Press "Alt" and "F11" at the same time to open the Visual Basic Editor.

    • 3

      Open your module by double clicking it in the left navigation, or create a new module by clicking "Insert > Module" from the top menu.

    • 4

      Type MkDir followed by the folder path in quotes into your VBA macro. In the example, you would type:
      MkDir "C:\MyNewFolder\"

    • 5

      Press "F5" to run your macro, and create the new folder.

Tips & Warnings

  • If the folder you're trying to create already exists, your macro will throw an error.

Related Searches:

References

  • Photo Credit keyboard image by Andrey Kurehin from Fotolia.com

Comments

You May Also Like

Related Ads

Featured