25/07/17 08:47:01.58 sGHKyXGW.net
>>410
Dirでワイルドカードが使えるので、こんな感じに仕上げてみた
※ヒットするパスの例 → C:\Documents\A001\B000X1\Excel\20250717\FileABC001.xlsx
HomePath = "C:\Documents"
SearchPath = "A???\B*\Excel\2025????\File*.xlsx"
ResultPath = HomePath
SearchPathList = Split(SearchPath, "\")
For I = 0 To UBound(SearchPathList)
If Dir(ResultPath) <> "" Then
ResultPath = "ファイルの下は何もないよ!"
Exit For
End If
FolderName = Dir(ResultPath & "\" & SearchPathList(I), vbDirectory)
If FolderName = "" Then
ResultPath = "そんなパスはないよ!"
Exit For
End If
ResultPath = ResultPath & "\" & FolderName
Next
MsgBox "これかな?" & vbCrLf & ResultPath