そこで、テキスト ボックスの入力を使用して別のシートで対応する値を検索する関数を作成しました。問題は、一致が見つからない場合、無限ループに陥ることです。クラッシュしないようにループを制限できますか? ループを制限するのではなく、別の解決策があれば、私はすべて耳にします。これが私が取り組んでいるものです:
Function Most_Recent_Deployment(Label1 As String, Label2 As String, Label3 As String) As Long
Dim all_rows As Range
Dim row As Range
Dim LastCell As Range
Dim LastCellRowNumber As Long
Set LastCell = Sheet7.Cells(Sheet7.Rows.Count, "A").End(xlDown).End(xlUp)
LastCellRowNumber = LastCell.row + 1
Set row = Sheet7.Range("A:A").Find(Label1, LookIn:=xlValues, After:=Cells(LastCellRowNumber, "A"), SearchDirection:=xlPrevious)
Do While row.row > 1
If (Sheet7.Cells(row.row, 2).Text = Label2) And (Sheet7.Cells(row.row, 3).Text = Label3) Then
Most_Recent_Deployment = row.row
Exit Function
End If
LastCellRowNumber = row.row
Set row = Sheet7.Range("A:A").Find(Label1, LookIn:=xlValues, After:=Cells(LastCellRowNumber, "A"), SearchDirection:=xlPrevious)
Loop
Most_Recent_Deployment = 0
End Function