こんな感じなのかなぁ・・
(環境を作るのが面倒なので、検証不十分ですけども)
Sub test()
Dim 行番号 As Long
Dim 版下P, 仕様P, 仮仕様P, ss, GP As String
Dim 版下確認, 仕様確認PDF, 仕様仮確認PDF, 仕様確認GP, 仕様仮確認GP As String
UserForm5.Show vbModeless 'フォームの表示
版下P = "\\Files_OK"
仕様P = "\\siyou_OK"
仮仕様P = "\\siyou_kari"
行番号 = ActiveCell.Row '選択行の取得
ss = Cells(行番号, 1).Value 'プライズ番号取得:例 O123456、Z123456など
GP = Right(Cells(行番号, 3).Value, 7): 'GP番号取得:例 GP1234567、GP2343456など
UserForm5.TextBox1.Text = getPdfName(版下P, "\" & "*.pdf", False)
UserForm5.TextBox2.Text = getPdfName(仕様P, "\" & ss & "*.pdf", False)
UserForm5.TextBox3.Text = getPdfName(仮仕様P, "\" & ss & "*.pdf", True)
UserForm5.TextBox4.Text = getPdfName(仕様P, "\" & GP & "*.pdf", False)
UserForm5.TextBox5.Text = getPdfName(仮仕様P, "\" & GP & "*.pdf", True)
End Sub
Private Function getPdfName(Path As Variant, pdfName As String, checkSubFolder As Boolean) As String
Dim buf As String, subFld As Object, aa As Object
buf = Dir(Path & pdfName)
If buf <> "" Then
getPdfName = buf
ElseIf checkSubFolder Then
With CreateObject("Scripting.FileSystemObject")
For Each subFld In .GetFolder(Path).SubFolders
getPdfName = getPdfName(subFld.Path, pdfName, checkSubFolder)
Exit Function
Next subFld
End With
End If
End Function