0

複数の基準でテーブルを検索しようとしていますが、それらの基準で複数の結果が得られた場合は、それらを表示したいと考えています。

これまで、私のコードは複数の条件を検索できましたが、結果が 1 つ見つかった時点で停止しました。

これはコード スニペットです: `

Set rngSearch = Sheets(Temp_Bereich).Range("A:M")

Set Found = rngSearch.Find(What:=Material_A, _
                           LookIn:=xlValues, _
                           LookAt:=xlWhole, _
                           SearchOrder:=xlByRows, _
                           SearchDirection:=xlNext, _
                           MatchCase:=False)
    
If Not Found Is Nothing Then
    
    Firstfound = Found.Address
    
    Do
        If Found.EntireRow.Range("B1").Value = Material_B And _
            Found.EntireRow.Range("C1").Value = Schmierzustand_AB And _
            Found.EntireRow.Range("G1").Value = Rauheit_A And _
            Found.EntireRow.Range("H1").Value = Rauheit_B And _
            Found.EntireRow.Range("D1").Value = Schmiermittel_AB Then Exit Do 'Match found
        
        Set Found = rngSearch.FindNext(After:=Found)
        If Found.Address = Firstfound Then Set Found = Nothing
        
    Loop Until Found Is Nothing
End If

If Not Found Is Nothing Then
    Application.Goto Found.EntireRow
    Haftreibwert.Value = Cells(Found.Row, 12).Value
    Gleitreibwert.Value = Cells(Found.Row, 13).Value
Else
    MsgBox "Es trifft leider nichts auf alle 6 Kriterien zu ", , "Kein Match gefunden"
End If
4

1 に答える 1