Many a times we need to select folder to get input data path during project automation. Which we will be the first activity before macro execution. Selecting folder using dialogue box is very vital task any any automation activity. it helps as a input data validation to use correct input data in further execution. Also, it help to achieve data quality in report automation task.

Folder selection can be implemented by writing a short VBA code,

Here is the code which show folder selection dialogue box:

Sub Select_Folder()
' Author: Dreams24
' Written for VBA Tricks and tips blog
   'Declare Variables
    Dim diaFolder As FileDialog
    ' Open the file dialog
    Set diaFolder = Application.FileDialog(msoFileDialogFolderPicker)
    diaFolder.AllowMultiSelect = False

    ' Message box to show selected folder path
    MsgBox "Folder Path is: " & diaFolder.SelectedItems(1)
    Set diaFolder = Nothing

End Sub