VBAでApplicationオブジェクトのFileDialogを使用することで、フォルダの選択ダイアログボックスを取得することができます。
Application.FileDialog プロパティ (Excel) | Microsoft Learn
Application.FileDialog
でフォルダのパスを取得するコードは以下になります。
Function GetFolderPath() As String
'###################################################################################
'フォルダ選択ダイアログを開き、選択したフォルダの絶対パスの末尾に
'\を付加してリターンする
'-----------------------------------------------------------------------------------
'戻り値:選択したフォルダの絶対パスの末尾に\を付加したもの
'###################################################################################
With Application.FileDialog(msoFileDialogFolderPicker)
If .Show Then
GetFolderPath = .SelectedItems(1) & "\"
End If
End With
End Function
GetFolderPath
関数に対してテストを行ってみます。
Sub TestGetFolderPath()
Dim folderPath As String
folderPath = GetFolderPath
MsgBox folderPath
End Sub
フォルダ選択画面が表示されるので、C:\GetFolderPathの中にあるfolderを選択してみます。

選択したフォルダのパスがメッセージボックスで表示されます。