During the automating some task in VBA, many times we need to check that a folder is exits or not. For example if you want to create or delete a folder using VBA then you should check first whether that folder exits for not. If that folder exits then you take your next action. It method can prevent you from an error.
Below the VBA code for Folder Existence Function.
Option Explicit Function Folder_Existence(MyPath As String) As Boolean Application.Volatile If VBA.Dir(MyPath, vbDirectory) = "" Then Folder_Existence = False Else Folder_Existence = True End If End Function
Click here to download this Excel workbook for practice.