The below VBA function uses the Dir VBA function to validate Folder Path.
'This function checks if given folder path is valid or not
Public Function CheckFolderExist(strFolderPath As String) As Boolean
'If Dir retunrs blank then it is invalid folder path
If Dir(strFolderPath, vbDirectory) = "" Then
CheckFolderExist = False
MsgBox "Invalid Folder Path!", vbCritical
'Else it is a valid folder path
Else
CheckFolderExist = True
MsgBox "Valid Folder Path!", vbInformation
End If
End Function
Explanation:Â If the function returns True then it is a valid folder path. If function returns False then it is invalid folder path.
Below VBA function uses File System Object to validate Folder path
'This function checks if given folder path is valid or not
'Microsoft Scripting Runtime reference is required to run this code
Public Function CheckFolderExist(strFolderPath As String) As Boolean
Dim objFileSystem As FileSystemObject
Set objFileSystem = New FileSystemObject
'If FolderExists function returns True then it is valid folder path
If objFileSystem.FolderExists(strFolderPath) = True Then
CheckFolderExist = True
MsgBox "Valid Folder Path!", vbInformation
'Else it is invalid folder path
Else
CheckFolderExist = False
MsgBox "Invalid Folder Path!", vbCritical
End If
End Function
Explanation:Â If the function returns True then it is a valid folder path. If function returns False then it is invalid folder path.
Excel Files and Sheets Consolidator is an MS Excel based data consolidation tool which can be used to consolidate data from multiple Excel Files or Excel Sheets. The tool supports multiple configurations such as Sheet Name, Sheet Index, Header Row and Non-Blank column to help consolidating accurate data.
VBA to Browse Outlook Folder Outlook is most commonly used emailing application used in the world. Many people spend their entire day on Outlook applications to read and respond to emails. To automate certain rule-based…
How to Add Outlook Reference in Excel VBA? To automate Outlook based tasks from Excel you need to add Outlook Object Library (Microsoft Outlook XX.X Object Library) in Excel References. You can follow below steps…
What is the Usage of sheet color in Excel? When we prepare a report or a dashboard it is easy to identify or analyze reports with a change of color sheet tabs. Analysts generally give…
VBA Code to Convert MM.DD.YYYY To DD.MMM.YYYY in Excel In different parts of the world, there are different languages spoken and written. With this, a VBA programmer also faces language related issues while writing a…
Colorindex in Excel VBA Today let’s try to understand how ColorIndex property in Excel VBA works. It is an easy and effective way to quickly complete the development. ColorIndex property is normally used by VBA…