File – Directory Functions

VBA File and Directory Functions can be use to handle with files, folders and directories. These are ChDir, ChDrive, CurDir, Dir, FileAttr, FileCopy, FileDateTime, FileLen, GetAttr, Kill, MkDir, Name, RmDir, SetAttr etc. These functions are Built-In functions. We can use these VBA File and Directory functions in either procedure or function. These functions we use in the VBA editor window in Excel. These File and Directory functions you can use any number of times in VBA macro codes.

We use these functions to create,delete, or rename folders. Store files in created folders. You can organize files, folders and directories.

Click on the following link to learn VBA File and Directory Functions in Excel.

VBA File and Directory Functions in Excel

VBA Create Folder with Today’s Date

VBA Create Folder with Today's Date

VBA Create Folder with Today’s or current Date. Today’s date is 3rd Oct 2019. We are checking specified folder is already exists in the specified folder. If it is not available then we are creating new folder using MkDir VBA function. The folder name always displays system current date. We use VBA Now function to …

VBA Create Folder with Today’s Date Read More »

VBA Create Folder on Desktop

VBA Create Folder on Desktop

VBA Create Folder on Desktop. In the below specified example we are using the Environment variable UserProfile to find the desktop location. You can change the folder path which you want to create on the desktop according to your requirement. We are checking specified folder is already exists on the desktop. If it is not …

VBA Create Folder on Desktop Read More »

VBA Remove Directory and its Content

VBA Remove Directory and its Content

VBA Remove specified directory and its content. In the following tutorial we have explained step by step instructions to run example macro. Table of Contents: Objective VBA Removing Directory and its Content Instructions to Run VBA Macro Code Other Useful Resources VBA Remove Directory and its Content Let us see an example macro VBA code …

VBA Remove Directory and its Content Read More »

VBA Count Files in Folder and Subfolders

VBA Count Files in Folder and Subfolders

VBA Count Number of Files in Folder and Subfolders. We are checking main folder and all the other available sub-folders to count number of files. We use recursive method to check each and every sub folder. In the following tutorial we have explain step by step instructions to run example macro. Table of Contents: Objective …

VBA Count Files in Folder and Subfolders Read More »

VBA Delete Empty Subfolders

VBA Delete Blank Subfolders

VBA Delete Empty Subfolders from a specified folder using VBA. First we are checking subfolder has files in it. Files are available we are not deleting that respective subfolder. If files are not available and now subfolder is empty then we are deleting that folder. In the following tutorial we have explained step by step …

VBA Delete Empty Subfolders Read More »

VBA Delete Empty Folder

VBA Delete Empty Folder

VBA Delete Empty Folder in Excel. We use VBA RmDir VBA function to delete only blank or empty folder. It throws an error, If any file exists in the specified folder. The following tutorial explains examples and step by step instructions for user reference. Table of Contents: Objective Example on VBA Blank or Empty Folder …

VBA Delete Empty Folder Read More »

VBA Delete File in Excel

VBA Delete File

VBA Delete File in Excel from a folder or directory. You can delete any file like Excel, Word, PowerPoint, CSV, Notepad etc. Let us see different examples in the following tutorial. We are using Kill statement to delete a file. Table of Contents: Objective Example on Deleting different type of File using Kill Statement Deleting …

VBA Delete File in Excel Read More »

VBA Delete All Files in Folder and Subfolders in Excel

VBA Delete Files in Folder and Subfolder

VBA Delete All Files in Folder and Subfolders in Excel. In the following tutorial we are using recursive method. It is nothing but looping through all folders until finishes all available folders. Let us see an example macro VBA code to delete files in folders and sub folders. You can also find the step by …

VBA Delete All Files in Folder and Subfolders in Excel Read More »

VBA Check If Folder Exists If Not Create It

VBA Check If Folder Exists If Not Create It

VBA Check If Folder Exists If Not Create It in specified name using VBA in Excel. We are using 2 methods to check folder exists or not. Those are Dir VBA function and FileSystemObject object. In the following tutorial let us see an example macro code. And also see the step by step instructions to …

VBA Check If Folder Exists If Not Create It Read More »

VBA Check If File Exists If Not Create It

VBA Check If File Exists If Not Create It

VBA Check If File Exists If Not Create It in Excel. If not create a new file with specified name using VBA in Excel. We are using 2 methods to check folder exists or not. Those are Dir VBA function and FileSystemObject object. In the following tutorial let us see an example macro code. And …

VBA Check If File Exists If Not Create It Read More »

VBA Delete All Files and Subfolders from a Folder

VBA Delete All Files and Subfolders

VBA Delete all Files and Subfolders form a folder using Excel VBA. You can delete all files using DeleteFile method of FileSystemObject. And delete all folders using DeleteFolder method of FileSystemObject. Table of Contents: Overview Delete All Files and Subfolders in a Folder using Excel VBA Example Instructions to Run VBA Macro Code Other Useful …

VBA Delete All Files and Subfolders from a Folder Read More »

VBA Delete All Files in a Folder

VBA Delete All Files in a Folder

VBA Delete All Files in a Folder in Excel Delete all Files in a Folder in Excel using VBA. If folder is empty, then no file is available to delete. In the following tutorial we have explained with example and step by step instructions for user reference. Table of Contents: Objective VBA Delete All Files …

VBA Delete All Files in a Folder Read More »

VBA Check If File Exits then Delete

VBA Check If File Exits then Delete

VBA Check If File Exits then Delete in Excel. If it is available then Delete file from the specified folder. In the following tutorial we have explained step by step instructions. Table of Contents: Objective VBA Checking If File Exits then Delete in Excel Instructions to Run VBA Macro Code Other Useful Resources VBA Check …

VBA Check If File Exits then Delete Read More »

Create Microsoft Scripting Runtime Reference

Microsoft Scripting Runtime Reference

Create Microsoft Scripting Runtime Library Reference. Here are the instructions to add reference before running below VBA macro code. Table of Contents: Objective Step by step instructions to add Microsoft Scripting Runtime Library reference Create FSO Object VBA FSO Auto List Members Enable VBA FSO Auto List Members Instructions to Run VBA Macro Code Other …

Create Microsoft Scripting Runtime Reference Read More »