0

我正在尝试将此公式转换为 VBA 代码,但不知道如何转换。

=IFERROR(INDEX($E$3:$E$10,MATCH($G3&I$2,$B$3:$B$10&$D$3:$D$10,0)),"")
4

1 回答 1

0

您可以尝试以下方法

Dim fndRng as Range
set firstAddr as String

' Update this to your sheet reference
With ActiveSheet
    set fndRng = .Range("B3:B10").find(Range("G3").Value2)
    If Not fndRng is nothing then
        firstAddr = fndRng.Address
        Do
            If fndRng.Offset(0,2).Value2 = .Range("I2").Value2 Then
                Exit Do
            End If
            Set fndRng = .Range("B3:B10").FindNext(fndRng)
        Loop Until fndRng is Nothing or fndRng.Address = firstAddr
    
        MsgBox fndRng.Address & ": " & fndRng.Offset(0, 3).Value2
    end if
End With
于 2022-01-19T16:35:32.483 回答